GNOME Bugzilla – Bug 578191
In CCode, Enums get declared after the classes
Last modified: 2009-04-07 13:51:37 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.
Created attachment 132238 [details] [review] Process enums seperately, writing them before other types. Please.
Confirming. With this patch my code finally compiled.
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