Skip to content

§9.9: ranges are absent from the precedence table, so 0..3 |> map(f) parses the pipe inside the range #3001

Closed

Description

@ehartford

Found while writing the D186 fixture (#2962).

fn main:
    for x in 0..3 |> map(it * 2): print(x)
error: undefined variable   (the `it` of the map)

The parser reads 0..(3 |> map(it * 2)). (0..3) |> map(it * 2) and a bound range work.

The §9.9 precedence table (and §30's copy) has no row for ../..=, so neither reading is ruled. Three-way: the spec is incomplete here. Proposal for the ruling: a range is a value like a sum, so .. sits above |> and ?? and below the comparisons: 0..n |> map(f) is (0..n) |> map(f), and a..b ?? c is (a..b) ?? c. Rust, for comparison, gives .. the lowest binary precedence. Go/Zig/Swift have no pipe. Spec words are Eric's; the parser change is one precedence level once ruled.

Activity

  1. added
    spec-gap
    on Nov 3, 2026
  2. added a commit that references this issue on Nov 7, 2026
  3. ehartford commented on Nov 7, 2026

    @ehartford
    ContributorAuthor

    Fixed in #3056 (merged as afbdbb1).

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

    spec-gap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions