You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ICE: inferred return joining a view return with a literal return (return x of &i32 beside return -1) #2325
fn find(xs: &List[i32], want: i32):
for x in xs:
if x == want: return x
return -1
fn main:
let xs: List[i32] = [3, 7]
print(f\"{find(&xs, 7)} {find(&xs, 9)}\")
Actual: internal compiler error: invalid MIR before codegen ... use rvalue type is incompatible with assign destination (dest ty=… kind=14, src … kind=1) in find.
The inferred return type joins &i32 (the view return) with the literal return; Sema then neither materializes return x to the owned value nor refuses the join, and MIR assigns an integer into a reference-typed return local.
Expected: the same answer as an if with mixed view and owned arms: the join is the owned value type (i32), return x materializes it, -1 is checked at i32. Returns are checked before the return type is inferred, so the view return needs its owned-demand adjustment recorded after inference (the d114-impl branch makes literal returns adapt to typed returns; the view case needs this).
Fixed on main (b050a01, PR #2587, stack #2588): one commit with the fixture test/behavior/behav_2325_inferred_return_from_view_loop.w, which failed before the fix and passes after; battery GREEN on the stack top 077d684 (669 s, pinned seed nightly-20261023-local-1).
Activity
A view return joined with an owned return is the owned value (#2325)
Six fixes from the issue backlog: #2545, #2524, #2334, #2325, #2443, #…
ehartford commentedon Oct 23, 2026
Fixed on main (b050a01, PR #2587, stack #2588): one commit with the fixture
test/behavior/behav_2325_inferred_return_from_view_loop.w, which failed before the fix and passes after; battery GREEN on the stack top 077d684 (669 s, pinned seed nightly-20261023-local-1).