fix(parser): any keyword works as a dot key (#542)#551
Merged
Conversation
The position after '.' admits nothing but a field name, so the
TOK_IDENT-only check in the three postfix sites (IDENT chain, paren,
dict literal) rejected programs with no ambiguity to protect against —
keys creatable by literal, dict_set, and json_decode ('loop', 'in',
'when', ...) were reachable only by bracket, and SYNTAX.md's
soft-keyword promise failed for d.prev/d.at.
tok_is_dot_key accepts TOK_IDENT plus the contiguous word-keyword run
TOK_IS..TOK_LOCAL (all lexed through the identifier path, so str_val
already carries the source word — no lexeme reconstruction needed);
the enum pins the contiguity constraint. Covers read, write, compound
assign, any chain depth.
Suite [118]: 49 checks — all 39 keywords, chains, json_decode, the
paren/dict-literal postfix sites, bracket/dot agreement, and a
keyword-still-a-keyword interaction (for x in d.in). SPEC (executable
example), SYNTAX, GRAMMAR, COMPARISON updated.
Mirror note: ouroboros frontend.eigs needs the matching dot-key change;
lands with the next EIGS_REF bump per the deferred-mirror pattern
(#326/#328, #355/#351).
Closes #542
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Dot access rejected keyword-named fields —
d.loop,d.in,d.whenwere parse errors while the same keys were creatable by literal,dict_set, andjson_decode, and readable by bracket. The position after.admits nothing but a field name, so there was no ambiguity to protect against (tier-2 full fix from the issue).tok_is_dot_key=TOK_IDENT+ the contiguous word-keyword runTOK_IS..TOK_LOCAL; all three postfix sites (IDENT chain, paren, dict literal) now use it. Keyword tokens already carry their lexeme instr_val(lexer identifier path), so no reconstruction was needed — the enum now pins the contiguity constraint.d["k"]unchanged.json_decode(the original DeslanStudios report), both inline postfix sites, bracket/dot agreement,for x in d.inkeyword-interaction.'.' wordproduction), COMPARISON.md.Mirror note (deferred-mirror pattern, #326/#328 · #355/#351)
ouroborossrc/frontend.eigsneeds the matching dot-key change; it lands with the nextEIGS_REFbump.Validation
detect_leaks=1: 2795/2795, exit 0, leak tally 0.Closes #542
🤖 Generated with Claude Code