Skip to content

Postfix inconsistency across primaries: NUM/STR/list literals reject .key (GRAMMAR.md says they take it) while f-strings take postfix undocumented #329

Description

@InauguralPhysicist

Found in an adversarial language review at 95a0d76.

docs/GRAMMAR.md's postfix note claims "postfix indexing and dot access apply to NUM, STR, IDENT, list literals, dict literals, and parenthesized expressions". Two divergences:

  1. The STR, NUM, and list-literal branches of parse_primary loop only on TOK_LBRACKET (src/parser.c:656, 667, 816) — no .key:
    y is [10, 20].x     # Parse error line 1: unexpected '.' in expression
    s is "ab".foo       # same
    
  2. F-strings (unlisted in the note) DO take postfix, because they desugar to a parenthesized expression (src/lexer.c:319):
    print of f"hello"[1]   # → e, rc=0
    

Either give all primaries the uniform postfix loop, or fix the note to match the implementation (and add FSTR to it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions