fix(tokens): Ignore hex literals with suffixes

Fixes #1469
This commit is contained in:
Ed Page committed 2026-01-19 08:07:22 -06:00
1 parent 7300bb0964
commit 207157952c
2 files changed
+8 -19

No files matched your search

@@ -1,11 +1,4 @@
bin.name = "typos"
stdin = ""
stdout = """
error: `afe` should be `safe`
╭▸ ./sample.cpp:2:18
│
2 │ uint8 i = 0x1afe23456UL;
╰╴ ━━━
"""
stdout = ""
stderr = ""
status.code = 2
+7 -11
View File
@@ -281,7 +281,13 @@ mod parser {
<T as Stream>::Slice: AsBStr + SliceLen + Default,
<T as Stream>::Token: AsChar + Copy,
{
('0', alt(('x', 'X')), take_while(1.., is_hex_digit_with_sep))
(
'0',
alt(('x', 'X')),
take_while(1.., is_hex_digit_with_sep),
take_while(0.., is_xid_continue)
.verify(|s: &<T as Stream>::Slice| std::str::from_utf8(s.as_bstr()).is_ok()),
)
.take()
.parse_next(input)
}
@@ -1270,11 +1276,6 @@ mod test {
case: None,
offset: 0,
},
Identifier {
token: "0x1afe23456UL",
case: None,
offset: 17,
},
Identifier {
token: "World",
case: None,
@@ -1294,11 +1295,6 @@ mod test {
case: None,
offset: 0,
},
Identifier {
token: "0x1afe23456UL",
case: None,
offset: 17,
},
Identifier {
token: "World",
case: None,