fix(keywords): fail loudly when a scanner tier is unregistered or contradicts grammar.js#38
Merged
Merged
Conversation
…tradicts grammar.js
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Adding a scanner tier without updating
SYMBOL_TIERhas broken the dictionary generator twice —KW_FILTER_IF, thenKW_G_ARGV— both times on the very change that introduced the tier. The existing unmapped-symbol assert did catch it, but only after mining, and it named the affected keyword (unmapped scanner symbol for by) rather than the file to edit.SYMBOL_TIERstays hand-written rather than derived. The tier genuinely is ingrammar.js—alias($.kw_g_argv, "arg")is exactly the mapping — butkw_dtandkw_lteach carry two aliases (dt/optandlt/opt), so deriving would have to guess, and a guess writes a plausible dictionary with a wrong tier instead of failing. Convention-based derivation fails too:KW_G_ARGVmust map toarg, notargv.Three checks, all running before mining so they fire at the source rather than downstream:
KW_*referenced by the scanner tables must appear inSYMBOL_TIER; the error names the file, the map's line, and the line to add.grammar.js,SYMBOL_TIERmust agree with it. The alias is authoritative, so a contradicting hand-written entry is a silent dictionary defect that nothing previously caught.SYMBOL_TIERmust still be one of that token's actual aliases, so a tier that is neither is caught.All three failure modes were verified by deliberately breaking each in turn and confirming the message points at the fix.
keywords.jsonregenerates byte-identical.Runs inside the existing
keywordsCI job, whose first step isnode scripts/gen-keywords.mjs— so these fire there, ahead of thegit diff --exit-code keywords.jsonsync check.