GNOME Bugzilla – Bug 629600
Assigning a struct method to a delegate generates malformed C-Code
Last modified: 2018-05-22 13:44:42 UTC
Created attachment 170209 [details] simple testcase If you assign a method to a delegate vala generates the following code: (*self).f_target = (*self), (*self).f_target_destroy_notify = NULL which causes the following gcc error: deleginstruct.vala.c:41: error: incompatible types when assigning to type ‘gpointer’ from type ‘testee’ vala should assign the pointer and maybe even set the destroy_notify for the struct
Reproducible in 0.18.0 Changing (*self) to self in the generated C code allows compilation.
The fix is trivial, but the semantics may not be what you expect, so I'm unsure whether to fix it or forbid using struct methods for delegates altogether. The problem is with owned delegates: a struct is not referenced counted, so what destroy notify should do? Shall we copy the struct? What kind of transfer ownership? And so on. All of this is very counter intuitive because structs are not referenced counted.
Created attachment 266036 [details] [review] Struct method delegate Reference patch, to not by committed by any means.
-- 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/131.