check lifetime assigment to unowned and weak reference
Submitted by Michele Dionisio
Link to original bug (#771594)
Description
Created attachment 335769 patch for detect possible lifetime error
In my opition it is usefull that vala raise an error (or as minimum) a warning if someone try to assign un an unowned reference something that have reduced lifetime.
for example a code like:
unowned string a;
{
string shorta = "sa";
a = shorta;
}
stdout.printf (a);
has to be detected and raise an error or warning on
a = shorta;
I'm working on a patch for that detection. There is 2 possible scenarious:
- assigment like in the example before
- call async function with .begin() syntax where you start executing an async function without wait the end, so the unowned parameter of the async function can became invalid.
for schenario 1. I have the patch attached
Patch 335769, "patch for detect possible lifetime error":
lifetime.patch