digitalmars.D.bugs - [Issue 9069] New: struct literals are treated as lvalues
- d-bugmail puremagic.com (46/46) Nov 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (16/16) Nov 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (9/9) Nov 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (17/21) Nov 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (11/11) Nov 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (10/10) Dec 02 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (11/11) Dec 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (10/10) Dec 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (10/10) Dec 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
- d-bugmail puremagic.com (9/9) Dec 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9069
http://d.puremagic.com/issues/show_bug.cgi?id=9069 Summary: struct literals are treated as lvalues Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: jmdavisProg gmx.com --- Comment #0 from Jonathan M Davis <jmdavisProg gmx.com> 2012-11-24 02:17:54 PST --- I thought that we'd finally fixed this, but I guess that it was changed back for some reason. With this code, struct S { int i; } S foo(ref S s) { return s; } S bar(int i) { return S(i); } void main() { S s = S(2); foo(s); //compiles as it should foo(S(5)); //compiles when it shouldn't foo(bar(5)); //fails to compile as it should } only the final call to foo gives an error, when only the first call should compile. The second call is succeeding when it should be failing. It makes _no_ sense to treat struct literals as lvalues. They're _not_ variables. Why on earth would struct literals be treated any differently from string literals or numeric literals in this regard? When it's come up in the newsgroups, I believe that the only person who has thought that this made any sense at all is Walter. And I thought that we'd finally gotten him to change it so that struct literals act like every other literal and are rvalues, but given that foo(S(5)) compiles, clearly that's not the case. It should be fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-11-24 03:04:42 PST --- I think this is the pull that should have fixed this: http://d.puremagic.com/issues/show_bug.cgi?id=5889 Also since a recent pull this (correctly) no longer compiles: struct S { } void test(ref S s = S()) { } So I think we've definitely agreed that literals are r-values. Maybe the OP code compiles because of an oversight or wrong revert? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 --- Comment #2 from Jonathan M Davis <jmdavisProg gmx.com> 2012-11-24 03:13:58 PST --- It was discussed in the thread on const ref in the dmd-beta group during the preparations for releasing 2.060, and I think that it was fixed and then unfixed then, but I'm not sure. Regardless, the code here compiles when it shouldn't, and that needs to be fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 --- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2012-11-24 05:42:18 PST --- (In reply to comment #2)It was discussed in the thread on const ref in the dmd-beta group during the preparations for releasing 2.060, and I think that it was fixed and then unfixed then, but I'm not sure. Regardless, the code here compiles when it shouldn't, and that needs to be fixed.This behavior is introduced in 2.059beta by: https://github.com/D-Programming-Language/dmd/pull/874 As far as I know, the main purpose was to avoid breaking existing code: struct S { bool opEquals(const ref S rhs) { ... } } void main() { S s; assert(s == S()); // translated to s.opEquals(S()) } But, I believe the behavior should be *fixed*. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull Version|unspecified |D2 --- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2012-11-24 07:16:40 PST --- https://github.com/D-Programming-Language/dmd/pull/1319 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 24 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mrmocool gmx.de --- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-02 10:59:44 PST --- *** Issue 7513 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 02 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 --- Comment #6 from github-bugzilla puremagic.com 2012-12-03 17:24:28 PST --- Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/5fb1348103930045604835ac40bb3a84106c7bf0 fix Issue 9069 - struct literals are treated as lvalues https://github.com/D-Programming-Language/dmd/commit/5b8827f3db5affdd4534cf131492fd92c6e10269 Merge pull request #1319 from 9rnsr/fix9069 Issue 9069 - struct literals are treated as lvalues -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 03 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 --- Comment #7 from github-bugzilla puremagic.com 2012-12-03 21:52:44 PST --- Commit pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/afed048033d976482739945f9ca4e8ca14271264 fixup for pull #1301 and #1309 By fixing bug 9069 and 9035, T.init always returns rvalue and ref cannot receive it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 03 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 --- Comment #8 from github-bugzilla puremagic.com 2012-12-03 22:01:02 PST --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/acf8a8934dff6b9cdfcc4d5f98b9b5c242b11ebd fixup for pull #1301 and #1309 By fixing bug 9069 and 9035, T.init always returns rvalue and ref cannot receive it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 03 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9069 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 17 2012