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 578191 - In CCode, Enums get declared after the classes
In CCode, Enums get declared after the classes
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.7.x
Other All
: Normal blocker
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-04-07 05:18 UTC by rainwoodman
Modified: 2009-04-07 13:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Process enums seperately, writing them before other types. (3.46 KB, patch)
2009-04-07 05:40 UTC, rainwoodman
reviewed Details | Review

Description rainwoodman 2009-04-07 05:18:57 UTC
Please describe the problem:
The following vala program(which is a typical usage) produces uncompilable CCode:

// enum.vala
public enum ENUM {
	foo
}
public class CLASSA {
	public ENUM enum_value;
}

// classb.vala
public class CLASSB {
	public CLASSA class_a;
	public void func() {
		if(class_a.enum_value == ENUM.foo) {
			
		}
	}
}

valac -C enum.vala class_b.vala

Steps to reproduce:


Actual results:
In classb.c 

....

struct _CLASSA {
┊   GTypeInstance parent_instance;
┊   volatile int ref_count;
┊   CLASSAPrivate * priv;
┊   ENUM enum_value;
};

struct _CLASSAClass {
┊   GTypeClass parent_class;
┊   void (*finalize) (CLASSA *self);
};

typedef enum  {
┊   ENUM_foo
} ENUM;

....

Which is uncompilable.


Expected results:
In CCode, enums should be declared before anything.


Does this happen every time?
Yes.

Other information:
It is a very annoying bug.
Comment 1 rainwoodman 2009-04-07 05:40:02 UTC
Created attachment 132238 [details] [review]
Process enums seperately, writing them before other types.

Please.
Comment 2 Víctor Manuel Jáquez Leal 2009-04-07 10:22:06 UTC
Confirming. With this patch my code finally compiled.
Comment 3 Jürg Billeter 2009-04-07 13:51:37 UTC
Thanks for the patch. However, this bug has already been fixed two days ago. If you still see this issue with master, please reopen.

commit db086d961820326ee4468f0eecb7e3c4e172b7bf
Author: Jürg Billeter <j@bitron.ch>
Date:   Sun Apr 5 22:22:46 2009 +0200

    Fix declaration order of classes and field types