Skip to content

fix(parser): any keyword works as a dot key (#542)#551

Merged
InauguralPhysicist merged 1 commit into
mainfrom
fix/542-keyword-dot-keys
Jul 11, 2026
Merged

fix(parser): any keyword works as a dot key (#542)#551
InauguralPhysicist merged 1 commit into
mainfrom
fix/542-keyword-dot-keys

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

Summary

Dot access rejected keyword-named fields — d.loop, d.in, d.when were parse errors while the same keys were creatable by literal, dict_set, and json_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 run TOK_IS..TOK_LOCAL; all three postfix sites (IDENT chain, paren, dict literal) now use it. Keyword tokens already carry their lexeme in str_val (lexer identifier path), so no reconstruction was needed — the enum now pins the contiguity constraint.
  • Covers read, write, compound assign, any chain depth; d["k"] unchanged.
  • Suite [118] (49 checks): all 39 keywords, chains, json_decode (the original DeslanStudios report), both inline postfix sites, bracket/dot agreement, for x in d.in keyword-interaction.
  • Docs: SPEC.md (executable example), SYNTAX.md, GRAMMAR.md ('.' word production), COMPARISON.md.

Mirror note (deferred-mirror pattern, #326/#328 · #355/#351)

ouroboros src/frontend.eigs needs the matching dot-key change; it lands with the next EIGS_REF bump.

Validation

  • Release: 2795/2795 passed.
  • ASan+UBSan detect_leaks=1: 2795/2795, exit 0, leak tally 0.

Closes #542

🤖 Generated with Claude Code

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>
@InauguralPhysicist InauguralPhysicist merged commit a3f5250 into main Jul 11, 2026
17 checks passed
@InauguralPhysicist InauguralPhysicist deleted the fix/542-keyword-dot-keys branch July 11, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dot access rejects keyword-named fields (d.loop, d.in, d.when) — keys reachable by literal, bracket, and json_decode are unreachable by .

1 participant