fix: unquoted name with non-first high character#50
Open
gthb wants to merge 2 commits into
Open
Conversation
Reproduce bug: `fræði!A1` tokenizes as `fr` + `æði!A1` instead of one reference. Likewise `fræði` (as a name reference) tokenized as `fr` + `æði`. Cause: in `lexNameFuncCntx` the loop tests the token's _first_ character `s` against the high-char range (`s > 180`) but indexes `ALLOWED` with the _current_ character `c`. Names that _start_ with a high character (`æði`) are OK, because `s > 180` is true for them. For a name that starts with an ASCII character, `s > 180` is false, so a later high character (e.g. æ, code 230) indexes `ALLOWED` out of bounds, resulting in `undefined`, treated as invalid, and the name splits at that character.
Correct the loop to check the current character `c`, not the initial character `s`, against the high-char range.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix bug:
fræði!A1tokenizes asfr+æði!A1instead of one reference. Likewisefræði(as a name reference) tokenizes asfr+æði.Cause: in
lexNameFuncCntxthe loop checks the token's first charactersagainst the high-char range (s > 180) but indexesALLOWEDwith the current characterc.Names that start with a high character (
æði) are unaffected, becauses > 180is true for them. That is why existing tests did not catch this.For a name that starts with an ASCII character,
s > 180is false, so a later high character (e.g. æ, code 230) indexesALLOWEDout of bounds, resulting inundefined, which is falsy, so the name splits at that character.Fix: correct the loop to check the current character
c, not the initial characters, against the high-char range.