Repository navigation
Terminate keywords at HCL identifier boundaries - #108
Merged
Merged
Conversation
HCL identifiers may contain `-`, but most keyword and constant rules
ended with `\b`, which treats `-` as a boundary. So `true-ish`,
`var-x`, `count-x = 1` or `[for-x]` highlighted a keyword followed by
a minus operator instead of a single identifier.
Replace the trailing `\b` with `{{break}}` in the rules for named
values, type keywords, language constants, template directives,
`terraform import`, the `count`/`for_each` attribute keys and the
tuple `for` and for-expression `in`/`if` keywords.
Numeric literals keep `\b` because `-` ends a number.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Every context with a keyword rule also has a rule that consumes whole
identifiers from their first character. Since the leftmost match wins,
a keyword rule can no longer match in the middle of an identifier such
as `xtrue` or `a-in`, which makes the leading `\b` redundant.
Patterns now starting with `{{` are quoted to remain valid YAML.
`\b` stays in the numeric literals, in `arn:aws:` inside strings and in
the plan syntax, whose contexts have no such identifier rule.
Add regression tests for identifiers ending with a keyword, notably
`{ waitfor: 1 }`, which relies on the native object key parsing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
deathaxe
approved these changes
Nov 10, 2026
FichteFoll
force-pushed
the
bugfix/keyword-break-termination
branch
2 times, most recently
from
November 10, 2026 17:43
337af00 to
c684c91
Compare
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.
Keywords were not properly terminated by
-before. Additionally, since we currently adhere to token termination etiquette, we can drop leading\banchors for all our keyword and identifier matches.Note that this relies on the removal of the JSON
object-bodycontext via #107, which matches\Sas invalid and would otherwise allow keywords to begin mid-word.