28651, "jabraham17", "Should it be possible to reassign dead owned variables?", "2026-04-07T20:53:59Z"
In a recent discussion about examples in the spec, something that came up was if it should be possible to reassign dead variables.
For example
class C {}
proc take(in c) {}
proc main() {
var c = new C();
take(c); // make 'c' dead
c = new C(); // should this be possible?
}
Other languages that have similar ownership models (like C++ and rust) do allow you to do this.
My understanding from @bradcray is that our current implementation of dead variables is based on copy-elision, which is based on if any mention of the variable appears after an assignment/copy-init and that it is likely "intended" that you cannot do this. But I would be very curious in @mppf's thoughts here.
This seems like an attractive feature to allow re-using variables with dead owned classes