GNOME Bugzilla – Bug 771594
check lifetime assigment to unowned and weak reference
Last modified: 2018-05-22 15:38:32 UTC
Created attachment 335769 [details] [review] 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: 1. assigment like in the example before 2. 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
This is quite an if-clause cascade and the changes of codegen/valaccodebasemodule.vala are superfluous.
About changes in codegen/valaccodebasemodule.vala. It is true. I fix 2 patch in one. Sorry. But I think it is coninient to apply the patch of codegen/valaccodebasemodule.vala because it only add 'static' on method that can be static so it is not possible to introduce regression and increase speed and code mantenibility. About the patch itself, have you any comment? Is it for you usefull to coninue to works on in to fully support these type of bug detection and if it is safe replace the warning with an error? I have some doubus about all the if clauses. The idea was only to detect unowned reference to not null or constant. The other idea was also to alert about 'unown' used on type like int that is surelly copied. Have you any ideas, suggestions? I will appreciate a lot. regards
I don't know enough to comment on that deeply nested ifs. However, I suggest that one patch should only deal with one issue. In this patch, in addition to trying to fix the bug, you also made two functions static (unless making them static is part of the bug fix).
Sorry for my unnecessary comment as the issue was already noted. I should have read the other comments first before commenting on the patch.
@michele, I will try to take a look soon.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/553.