fix(fmt): identifiers equal to a keyword are not quoted #132 (#137)

This commit is contained in:
Koi to Coco 2025-09-05 01:49:05 +08:00 committed by GitHub
parent 758bd63621
commit 564d4aeead
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -186,6 +186,12 @@ pub(crate) fn is_plain_ident(ident: &str) -> bool {
.map(|c| c == '.' || c == '-' || c == '+')
== Some(true)
&& ident_bytes.get(1).map(|c| c.is_ascii_digit()) == Some(true))
&& ident != "inf"
&& ident != "-inf"
&& ident != "nan"
&& ident != "true"
&& ident != "false"
&& ident != "null"
}
#[cfg(test)]