Skip to content

Commit

Permalink
debug assert in unicode escape sequence parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
zrho committed Nov 11, 2024
1 parent 9801860 commit 7eab2e2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hugr-model/src/v0/text/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,10 @@ impl<'a> ParseContext<'a> {
_ => unreachable!(),
},
Rule::string_unicode => {
let code_str = &token.as_str()[3..token.as_str().len() - 1];
let token_str = token.as_str();
debug_assert_eq!(&token_str[0..3], r"\u{");
debug_assert_eq!(&token_str[token_str.len() - 1..], "}");
let code_str = &token_str[3..token_str.len() - 1];
let code = u32::from_str_radix(code_str, 16).map_err(|_| {
ParseError::custom("invalid unicode escape sequence", token.as_span())
})?;
Expand Down

0 comments on commit 7eab2e2

Please sign in to comment.