GNOME Bugzilla – Bug 585158
Out of scope variable access leads into a gcc error
Last modified: 2009-06-08 15:50:05 UTC
I used the GTK+ Sample given on the vala web page. I just replaced source.label = "Thank you"; with button.label = "Thank you"; Here is the code: using Gtk; static int main (string[] args) { Gtk.init (ref args); var window = new Window (WindowType.TOPLEVEL); window.title = "First GTK+ Program"; window.set_default_size (300, 50); window.position = WindowPosition.CENTER; window.destroy += Gtk.main_quit; var button = new Button.with_label ("Click me!"); button.clicked += (source) => { button.label = "Thank you"; }; window.add (button); window.show_all (); Gtk.main (); return 0; } When compiling this, I get a GCC compilation error telling me that the "button" variable is not accessible. I don't know if the vala language allows to access to "button" from the inline button.clicked hanlder. If i isn't, I should get a valac error. If it is allowed, the generated code must be wrong. Regards
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of 554781 ***