Skip to content
Snippets Groups Projects
Commit fad9e6f3 authored by stratact's avatar stratact Committed by Michael Aaron Murphy
Browse files

Check for non ascii alphanumeric variable names

parent fd237179
No related branches found
No related tags found
No related merge requests found
......@@ -27,11 +27,9 @@ where
}
pub fn is_valid_name(name: &str) -> bool {
if !(name.as_bytes()[0] as char).is_numeric() {
!name.chars().any(|c| !(c.is_alphanumeric() || c == '_'))
} else {
false
}
let mut bytes = name.bytes();
bytes.next().map_or(false, |b| b.is_ascii_alphabetic())
&& bytes.all(|b| b.is_ascii_alphanumeric() || b == b'_')
}
pub(crate) fn parse(code: &str) -> Statement {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment