File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ fn parse_literal_as_bool(node: RefNode, ast: &sv_parser::SyntaxTree) -> Result<b
8080 RefNode :: BinaryValue ( b) => {
8181 let loc = b. nodes . 0 ;
8282 let val = ast. get_str ( & loc) . unwrap ( ) ;
83- let num = u64:: from_str_radix ( val, 2 ) . unwrap ( ) ;
83+ let num = u64:: from_str_radix ( val, 2 )
84+ . map_err ( |_e| format ! ( "Could not parse binary value {val} as bool" ) ) ?;
8485 match num {
8586 1 => Ok ( true ) ,
8687 0 => Ok ( false ) ,
@@ -90,7 +91,8 @@ fn parse_literal_as_bool(node: RefNode, ast: &sv_parser::SyntaxTree) -> Result<b
9091 RefNode :: HexValue ( b) => {
9192 let loc = b. nodes . 0 ;
9293 let val = ast. get_str ( & loc) . unwrap ( ) ;
93- let num = u64:: from_str_radix ( val, 16 ) . unwrap ( ) ;
94+ let num = u64:: from_str_radix ( val, 16 )
95+ . map_err ( |_e| format ! ( "Could not parse hex value {val} as bool" ) ) ?;
9496 match num {
9597 1 => Ok ( true ) ,
9698 0 => Ok ( false ) ,
@@ -100,7 +102,9 @@ fn parse_literal_as_bool(node: RefNode, ast: &sv_parser::SyntaxTree) -> Result<b
100102 RefNode :: UnsignedNumber ( b) => {
101103 let loc = b. nodes . 0 ;
102104 let val = ast. get_str ( & loc) . unwrap ( ) ;
103- let num = val. parse :: < u64 > ( ) . unwrap ( ) ;
105+ let num = val
106+ . parse :: < u64 > ( )
107+ . map_err ( |_e| format ! ( "Could not parse decimal value {val} as bool" ) ) ?;
104108 match num {
105109 1 => Ok ( true ) ,
106110 0 => Ok ( false ) ,
You can’t perform that action at this time.
0 commit comments