Skip to content

Parser: a tuple field access cannot be followed by '.' — t.0.len() and t.0.1 lex '0.x' as a float #1450

Closed

Description

@ehartford

Spec: §4.8 Tuples ("Access by index: let x = pair.0").

A tuple field access followed by another . does not parse: the lexer reads 0.len / 0.1 after the dot as a float literal.

fn main:
    let t = ("ab".clone(), 3)
    print(t.0.len())
error: expected identifier
 --> tup.w:3:13
3 |     print(t.0.len())
  |             ^^
error: expected ')'
error: expected declaration (fn, type, enum, let, use, extern)

Nested access fails the same way:

fn main:
    let t = ((1, 2), 3)
    print(t.0.1)

Inside a function after fn main the cascade also reports "file has both fn main and top-level executable statements", which is a follow-on of the parse failure, not a real problem.

Expected: t.0.len() calls len on the first element (prints 2); t.0.1 is the nested field (prints 2).

Workaround: (t.0).len().

Found while writing the #1406 fixtures (installed nightly-20260922-local-1-8c859a7d0559 and a stage1 of origin/main 1c76062).

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Verified fixed on main 55739d4 (release binary): t.0.len() and t.0.1 print 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions