After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 553928 - ModuleInit generated code depends on source file order in the valac command
ModuleInit generated code depends on source file order in the valac command
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.3.x
Other All
: Normal major
: ---
Assigned To: Vala maintainers
Vala maintainers
: 572886 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-09-26 12:15 UTC by Andrea Del Signore
Modified: 2009-10-20 19:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
First vala source (342 bytes, text/plain)
2008-09-26 12:19 UTC, Andrea Del Signore
Details
Second vala source (172 bytes, text/plain)
2008-09-26 12:21 UTC, Andrea Del Signore
Details

Description Andrea Del Signore 2008-09-26 12:15:13 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.
Comment 1 Andrea Del Signore 2008-09-26 12:19:21 UTC
Created attachment 119413 [details]
First vala source
Comment 2 Andrea Del Signore 2008-09-26 12:21:03 UTC
Created attachment 119414 [details]
Second vala source
Comment 3 rainwoodman 2009-03-03 01:52:55 UTC
*** Bug 572886 has been marked as a duplicate of this bug. ***
Comment 4 Michael 'Mickey' Lauer 2009-10-20 11:06:16 UTC
Confirming. Still a problem with Vala 0.7.7.
Comment 5 Jürg Billeter 2009-10-20 19:58:34 UTC
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.