digitalmars.D.bugs - [Issue 4274] New: Better array of inner structs error message
- d-bugmail puremagic.com (32/32) Jun 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4274
- d-bugmail puremagic.com (12/12) Jun 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4274
- d-bugmail puremagic.com (9/9) Jun 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4274
- d-bugmail puremagic.com (11/11) Jun 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4274
- d-bugmail puremagic.com (8/8) Jun 05 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4274
- d-bugmail puremagic.com (10/10) Jun 08 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4274
- d-bugmail puremagic.com (14/14) Jul 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4274
http://d.puremagic.com/issues/show_bug.cgi?id=4274 Summary: Better array of inner structs error message Product: D Version: future Platform: x86 OS/Version: Windows Status: NEW Keywords: diagnostic Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This wrong D2 program: void main() { struct Foo { void bar() {} } auto foos = new Foo[1]; // line 5 } At compile time dmd v2.046 prints: temp.d(5): Error: cannot have array of inner structs Foo But for D newbies coming from C or C++ can find that error message cryptic. Using a static struct solves this problem. So a possible error message can be: temp.d(5): Error: cannot have array of inner structs Foo, you can use a 'static struct' instead. This improved error message is not perfect, but it seems better. (I don't understand why D error messages don't have the ending full stop.) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4274 nfxjfg gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nfxjfg gmail.com I don't understand why arrays of inner structs shouldn't be possible. Is this just another seemingly random restriction with no real foundation of the dmd compiler? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 05 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4274 Structs defined inside functions keep a hidden pointer field to the function they are into. If you return the array of nonstatic structs, the scope stops existing and this pointer points to garbage. To avoid this you need 'struct closures', but I prefer to avoid them. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 05 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4274 So what? You _can_ have an array of closures. Why not an array of nested structs? The compiler should obviously allocate all variables referenced by the struct on the heap, just like it is done with closures. Otherwise, it's an half-implemented garbage feature that should be removed before it causes any more harm. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 05 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4274 I just tested it, and it seems for nested structs, the compiler correctly allocates upvalues on the heap. The error message you're receiving doesn't make any sense. At least the reason for it must different. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 05 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4274 nfxjfg gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal Turning this into a "real" bug; maybe I'm wrong though. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 08 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4274 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Platform|x86 |All Resolution| |FIXED OS/Version|Windows |All Arrays of nested structs are now allowed (dmd 1.068 & dmd 2.053) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 01 2011