GNOME Bugzilla – Bug 553928
ModuleInit generated code depends on source file order in the valac command
Last modified: 2009-10-20 19:58:34 UTC
Please describe the problem: The code generated in the method decorated with the ModuleInit attribute will register just the classes contained in the source files specified before the source file that contains the "ModuleInit" method. Steps to reproduce: 1. compile 2 versions of the same sources with these commands valac -d 1 --save-temps -C strange-bug-class.vala strange-bug.vala --pkg glib-2.0 --pkg gmodule-2.0 and valac -d 2 --save-temps -C strange-bug.vala strange-bug-class.vala --pkg glib-2.0 --pkg gmodule-2.0 2. compare the generated c code: strange-bug$ diff -u 1 2 diff -u 1/strange-bug.c 2/strange-bug.c --- 1/strange-bug.c 2008-09-26 14:05:10.000000000 +0200 +++ 2/strange-bug.c 2008-09-26 14:05:27.000000000 +0200 @@ -73,7 +73,6 @@ GType register_plugin (GTypeModule* module) { g_return_val_if_fail (G_IS_TYPE_MODULE (module), 0UL); - strange_class_register_type (module); strange_bug_register_type (module); return STRANGE_TYPE_BUG; } Actual results: you will see that 'register_plugin' in strange-bug.c doesn't register the 'strange class' type that is contained in the strange-bug-class.vala. Expected results: that the generated source code will be identical (more or less ;) ) Does this happen every time? yes Other information: That dependes on the source file order in the command line. In the example: strange-bug.vala contains the ModuleInit function strange-bug-class.vala contains just one class that derives from gobject valac -C strange-bug.vala strange-bug-class.vala .... will generate bad code but valac -C strange-bug-class.vala strange-bug.vala .... will generated the correct one only because strange-bug.vala is the last source file included in the command line.
Created attachment 119413 [details] First vala source
Created attachment 119414 [details] Second vala source
*** Bug 572886 has been marked as a duplicate of this bug. ***
Confirming. Still a problem with Vala 0.7.7.
commit 0e8eddd844f8f93ac36c39a1bddd89d8e216508f Author: Jürg Billeter <j@bitron.ch> Date: Tue Oct 20 21:56:36 2009 +0200 Register all types when using [ModuleInit] Fixes bug 553928.