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
80
80
RefNode :: BinaryValue ( b) => {
81
81
let loc = b. nodes . 0 ;
82
82
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" ) ) ?;
84
85
match num {
85
86
1 => Ok ( true ) ,
86
87
0 => Ok ( false ) ,
@@ -90,7 +91,8 @@ fn parse_literal_as_bool(node: RefNode, ast: &sv_parser::SyntaxTree) -> Result<b
90
91
RefNode :: HexValue ( b) => {
91
92
let loc = b. nodes . 0 ;
92
93
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" ) ) ?;
94
96
match num {
95
97
1 => Ok ( true ) ,
96
98
0 => Ok ( false ) ,
@@ -100,7 +102,9 @@ fn parse_literal_as_bool(node: RefNode, ast: &sv_parser::SyntaxTree) -> Result<b
100
102
RefNode :: UnsignedNumber ( b) => {
101
103
let loc = b. nodes . 0 ;
102
104
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" ) ) ?;
104
108
match num {
105
109
1 => Ok ( true ) ,
106
110
0 => Ok ( false ) ,
You can’t perform that action at this time.
0 commit comments