digitalmars.D.bugs - [Issue 11258] New: Static field access problem
- d-bugmail puremagic.com (35/35) Oct 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11258
- d-bugmail puremagic.com (7/8) Oct 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11258
- d-bugmail puremagic.com (31/35) Oct 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11258
- d-bugmail puremagic.com (14/15) Oct 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11258
- d-bugmail puremagic.com (9/24) Oct 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11258
- d-bugmail puremagic.com (7/10) Oct 14 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11258
http://d.puremagic.com/issues/show_bug.cgi?id=11258 Summary: Static field access problem Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: regression Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc struct Foo { static int spam = 1; } struct Bar { static assert(__traits(compiles, { auto x = Foo.spam; })); // line5 static void foo() { static assert(__traits(compiles, { auto x = Foo.spam; })); } } void main() {} With dmd 2.064beta this program gives: test.d(5): Error: static assert (__traits(compiles, () { auto x = Foo.spam; } )) is false In dmd 2.063 this used to work. (Additionally, I'd like those error messages to show less newlines). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11258In dmd 2.063 this used to work.This is a regression from 2.062, and same error occurs with 2.063. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11258 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALIDSorry, this is NOT a regression. Current behavior is intended. In class/struct DeclDefs scope, directly using function literal is not allowed. struct Bar { int var; auto dg = { return var; }; // Error: function literals cannot be class members } Against that, __traits(compiles) has *no* special handling. Therefore, struct Bar { int var; static assert(__traits(compiles, { return var; })); // catch "cannot be class members" error, then returns false } The static assert correctly fails. Therefor current behavior is intended. On the other hand, this error check is stopped inside typeof operator. It's also an intended behavior. So, in this case, please use is(typeof({ ... })) instead. ==== Note: The old bug, existed in 2.062 and earlier, was fixed in here: https://github.com/D-Programming-Language/dmd/commit/0679c4c31ba78853873933324c69cd90e7714d15#diff-ffa5582af7d723c487d4a11ac6743b85R84 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------In dmd 2.063 this used to work.This is a regression from 2.062, and same error occurs with 2.063.
Oct 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11258Sorry, this is NOT a regression. Current behavior is intended.Thank you Kenji, this was tricky for me. Regarding the extra newlines in the error message: test.d(5): Error: static assert (__traits(compiles, () { auto x = Foo.spam; } )) is false Do you want me to open another "minor importance" bug report on it? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11258Regarding the extra newlines in the error message: test.d(5): Error: static assert (__traits(compiles, () { auto x = Foo.spam; } )) is false Do you want me to open another "minor importance" bug report on it?I hope you that. And I'd ask you one question: If the lambda has quite big body, how it will be output? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11258I hope you that. And I'd ask you one question: If the lambda has quite big body, how it will be output?OK, I have opened Issue 11263 . -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 14 2013