Skip to content

Tuple rest patterns (§9.7): let (h, ..tail) fails to parse; let (a, ..) reports an arity mismatch #1366

Closed

Description

@ehartford

Spec §9.7 ("let destructuring") lists let (head, ..tail) = get_items() ("..rest captures remaining") under "All pattern forms are available in let/var bindings". Neither tuple-rest spelling works.

Repro (a stage1 built from origin/main 5fd93bc):

fn main:
    let (a, ..) = (10, 20, 30)
    let (h, ..tail) = (1, 2, 3)
    print(f"{a} {h} {tail.0}")

Actual: let (h, ..tail) gives error: expected ')' / expected '=' (a parse error), and let (a, ..) = (10, 20, 30) gives error: tuple pattern arity mismatch.
Expected: prints 10 1 2, with tail: (i32, i32).

Sema has a rest path for tuple destructuring (check_tuple_destructure, sub-tuple rest binding), but it hangs off NK_TUPLE_DESTRUCTURE, which the parser no longer emits. Patterns go through NK_PAT_TUPLE → check_pattern, which has no rest handling.

Workaround: name every element.

Found while building the #1354 matrix.

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Verified fixed on main 55739d4 (release binary): let (a, ..) and let (h, ..tail) print 10 1 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