From 34339ecae6c4d3284a099d34f09674b4c8bdfd62 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 18 Aug 2026 16:44:27 +0200 Subject: Do not mark some valid identifiers as invalid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some identifiers like "@aa" were marked as invalid as "aa" is a potentially hexadecimal value, but the "@" symbol actually disambiguates this situation. Hence, if a non-alphanumeric character (that the parser liked) is actually found, ensure it cannot be considered as an hexadecimal value. Provide also a test of is_valid_identifier(). The list is certainly not exhaustive, but it should be good enough coupled with end-to-end tests. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/node.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs index 357b9e0..dac131a 100644 --- a/lib/xixanta/src/node.rs +++ b/lib/xixanta/src/node.rs @@ -69,6 +69,8 @@ impl PString { if c > 'f' && c <= 'z' { valid_hex = false; } + } else { + valid_hex = false; } } @@ -512,4 +514,29 @@ mod tests { assert_eq!(is_asan_friendly_name(&string), expect); } } + + #[test] + fn is_valid_identifier() { + let tests = vec![ + ("", false), + ("valid", true), + ("invalid::scoped", false), + ("x", false), + ("aaaa", false), + ("123", false), + ("@aa", true), + ]; + + for (name, expect) in tests { + let ps = PString { + value: name.to_string(), + line: 0, + start: 0, + end: 0, + }; + + let res = ps.is_valid_identifier(false).is_ok(); + assert_eq!(res, expect); + } + } } -- cgit v1.2.3