Skip to content

Sema: collect[C]() over a value that is not an iterator is refused by name, not left to MIR (#2319) - #2661

Merged
ehartford merged 1 commit into
fix-2326from
fix-2319
Oct 25, 2026
Merged

ehartford merged 1 commit into
fix-2326from
fix-2319

Conversation

@ehartford

@ehartford ehartford commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: check_call's x.collect[C]() branch (src/SemaCheck.w) returned
collect_target_type_from_callee, which returns 0 with no diagnostic when the
receiver has no iterator element type (a List: xs.map(f) is already a
List). Sema left the call unresolved and silent. lldb:
MirBody.require_call_contract(call_id=2) <- require_generic_call_contract <-
lower_method_call (MirLower.w) via method_is_unresolved, then "BUG: user
generic call lacks a concrete contract: body=…(main) call=2 … sig=-1 mono=0".
The unbracketed .collect() already said "unknown method 'collect' for type
'List[isize]'".

Over a receiver that is not an iterator, a user Iter[T] or a generator:
"collectC gathers an iterator, and List[isize] is not one:
.iter().collect[C]() gathers its elements".

Test: test/compile_errors/err_2319_collect_over_a_list.w. The installed
compiler reaches the MIR BUG.

Closes #2319

… name, not left to MIR (#2319)

Root cause: check_call's `x.collect[C]()` branch (src/SemaCheck.w) returned
collect_target_type_from_callee, which returns 0 with no diagnostic when the
receiver has no iterator element type (a List: `xs.map(f)` is already a
List). Sema left the call unresolved and silent. lldb:
MirBody.require_call_contract(call_id=2) <- require_generic_call_contract <-
lower_method_call (MirLower.w) via `method_is_unresolved`, then "BUG: user
generic call lacks a concrete contract: body=…(main) call=2 … sig=-1 mono=0".
The unbracketed `.collect()` already said "unknown method 'collect' for type
'List[isize]'".

Over a receiver that is not an iterator, a user Iter[T] or a generator:
"collect[C]() gathers an iterator, and `List[isize]` is not one:
`.iter().collect[C]()` gathers its elements".

Test: test/compile_errors/err_2319_collect_over_a_list.w. The installed
compiler reaches the MIR BUG.
@ehartford
ehartford added this pull request to stack #2668 October 25, 2026 22:01
@ehartford ehartford changed the title fix 2319 Sema: collect[C]() over a value that is not an iterator is refused by name, not left to MIR (#2319) Oct 25, 2026
@ehartford
ehartford marked this pull request as ready for review October 25, 2026 22:13
@ehartford
ehartford merged commit da3c86e into main Oct 25, 2026
@ehartford
ehartford deleted the fix-2319 branch October 25, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant