28468, "DanilaFe", "[Bug]: 'if'-'else' crosstalk during 'nil' checking", "2026-02-27T20:36:17Z"
This program doesn't compile:
class C {}
proc foo(in x: owned C) {}
proc lol(in x: owned C) {
var b = true;
if b {
foo(x); // <-------------------------------------------
} else { // |
writeln(x); // error, mention of dead variable, deleted here
}
}
lol(new C());
The error:
/ATO/code.chpl:4: In function 'lol':
/ATO/code.chpl:9: error: mention of non-nilable variable after ownership is transferred out of it
/ATO/code.chpl:7: note: ownership transfer occurred here
This is incorrect. While it's true that x was transferred into foo in the if branch, the else branch is mutually exclusive, and thus, x should still be valid there.