Skip to content

ICE: xs.map(f).collect[List]() on a List: "user generic call lacks a concrete contract" #2319

Closed

Description

@ehartford

Calling .collect[...]() on the result of List.map (the LIST_MAP intrinsic) reaches MIR with no concrete contract and stops the compiler instead of compiling or being refused by Sema.

fn main:
    let xs = [1, 2]
    let ys: List[i32] = xs.map(it + 1).collect[List]()
    print(ys.len())
BUG: user generic call lacks a concrete contract: body=981(main) call=2 node=10710 sig=-1 mono=0 [src/MirLower.w:18241 MirModule.validate_generic_call_contracts]

Same with collect[List[str]]() and with str.split(..).map(it.to_owned()).collect[List](). xs.iter().map(it + 1).collect[List]() works. With .collect() and no explicit argument it fails with only error: run failed, which is a second defect: no diagnostic names the problem.

Expected: List.map followed by collect compiles, as the iterator form does. Or, if List.map already returns a List and collect is not a List method, Sema refuses it with a named error before MIR.

Workaround: .iter().map(...). Found by a one-liner tool during D114.

Activity

  1. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced; the internal error is still reached.

    $ cat main.w
    fn main:
        let xs = [1, 2]
        let ys: List[i32] = xs.map(it + 1).collect[List]()
        print(ys.len())
    $ with run main.w
    BUG: user generic call lacks a concrete contract: body=1211(main) call=2 node=15350 sig=-1 mono=0 [src/MirLower.w:19505 MirModule.validate_generic_call_contracts]
    

    pre-release: an internal error on ordinary iterator code.

  2. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by e3b0ad0 (PR #2661, stack #2668; battery green on the stack top 9f92dbb). The commit message names the root-cause line and the regression test.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions