digitalmars.D.bugs - [Issue 6318] New: module isn't fully processed under weird conditions
- d-bugmail puremagic.com (74/74) Jul 14 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6318
- d-bugmail puremagic.com (19/19) Jul 14 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6318
- d-bugmail puremagic.com (19/19) Jul 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6318
- d-bugmail puremagic.com (12/12) Jul 15 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6318
http://d.puremagic.com/issues/show_bug.cgi?id=6318 Summary: module isn't fully processed under weird conditions Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: mrmocool gmx.de --- Comment #0 from Trass3r <mrmocool gmx.de> 2011-07-14 10:47:22 PDT --- One of the weirdest bugs I've ever encountered. Set up a directory named 'basic'. Inside there 3 files: module basic.Messages; //import basic.utils; // for flattenNamedEnum pragma(msg, "foo"); enum Severity { NOTE, } pragma(msg, flattenNamedEnum!Severity); pragma(msg, "bar"); // definition of enum Msg is normally mixed in here ==== module basic.Bar; import basic.Handle; import basic.Messages; class Bar { public: enum Level { Ignored, } void bla(Msg msg) { } } ==== module basic.Handle; import basic.Bar; void foo(Bar.Level level) { } I compiled it from inside the folder with 'dmd -c -I.. Bar.d Handle.d' Bar.d(13): Error: undefined identifier Msg foo Note how basic.Messages is only evaluated to a certain degree. The same happens with dmd -c -I.. Bar.d Handle.d Messages.d dmd -c -I.. Bar.d Messages.d Handle.d Only with 'dmd -c -I.. Handle.d Bar.d' it yields foo ../basic/Messages.d(14): Error: template instance template 'flattenNamedEnum' is not defined __error bar Bar.d(16): Error: undefined identifier Msg And with 'dmd -c -I.. Messages.d Bar.d Handle.d': foo Messages.d(14): Error: template instance template 'flattenNamedEnum' is not defined __error bar Bar.d(16): Error: undefined identifier Msg Also note that adding the definition of Msg by hand like enum Msg { f } or commenting out the flattenNamedEnum mixin also shows similar results. Can anyone confirm this? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 14 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6318 --- Comment #1 from Trass3r <mrmocool gmx.de> 2011-07-14 16:09:47 PDT --- Well, if ever needed, here's basic.utils: //! bring named enum members into current scope string flattenNamedEnum(EnumType)() if (is (EnumType == enum)) { string s = ""; foreach (i, e; __traits(allMembers, EnumType)) { s ~= "alias " ~ EnumType.stringof ~ "." ~ __traits(allMembers, EnumType)[i] ~ " " ~ __traits(allMembers, EnumType)[i] ~ ";\n"; } return s; } Pulling enum Level out of Bar also seems to 'resolve' this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 14 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6318 --- Comment #2 from Trass3r <mrmocool gmx.de> 2011-07-15 05:00:51 PDT --- And for completeness the Msg generation from basic.Messages: private immutable records = [ ["bla", "blub"], ]; mixin (generateMsgEnum()); private string generateMsgEnum() { string res = " enum Msg : string\n{\n"; foreach (msg; .messageRecords) res ~= " " ~ msg[0] ~ " = `" ~ msg[1] ~ "`,\n"; res ~= "}\n"; return res; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 15 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6318 --- Comment #3 from Trass3r <mrmocool gmx.de> 2011-07-15 05:11:03 PDT --- If this has to do with dmd exiting early because of errors, why is there no "fatal error: too many errors occured"? If it has to do with the cyclic import, why is Messages affected by that? In the import graph it is a sink (or source, depending on how you define the directions). (Of course utils will be the sink if you include it, but that doesn't change much) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 15 2011