digitalmars.D.bugs - [Issue 11270] New: [REG 2.064] Initialization of struct in constructor
- d-bugmail puremagic.com (35/35) Oct 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11270
- d-bugmail puremagic.com (9/16) Oct 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11270
- d-bugmail puremagic.com (26/26) Oct 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11270
- d-bugmail puremagic.com (14/40) Oct 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11270
- d-bugmail puremagic.com (8/8) Oct 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11270
- d-bugmail puremagic.com (13/16) Oct 15 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11270
http://d.puremagic.com/issues/show_bug.cgi?id=11270 Summary: [REG 2.064] Initialization of struct in constructor Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: regression Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: code benjamin-thaut.de PDT --- The following code used to work dmd 2.064 beta 1 and all versions before that. It just broke on the latest version of the 2.064 branch on git. repro.d(13): Error: cannot implicitly convert expression (f) of type float to netvar!float Although I'm not really sure if this is a bug or if the code is invalid and just used to work because of other bugs. Repro case: struct netvar(T) { T value; alias value this; void opAssign(T newVal){ value = newVal; } } void main(string[] args) { float f = 2.0f; netvar!float f2 = f; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11270The following code used to work dmd 2.064 beta 1 and all versions before that. It just broke on the latest version of the 2.064 branch on git. repro.d(13): Error: cannot implicitly convert expression (f) of type float to netvar!floatWith 2.057-2.063, same error occurs for the code.Although I'm not really sure if this is a bug or if the code is invalid and just used to work because of other bugs.As far as I know, the repro case is invalid. On the variable initialization `netvar!float f2 = f;` opAssign never invoked. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11270 PDT --- Sorry, I reduced the repro case to much. Here is the actual repro case I had first: struct netvar(T) { T value; alias value this; void opAssign(T newVal){ value = newVal; } } class Foo { netvar!float f; this(float f) { this.f = f; } } void main(string[] args) { new Foo(2.0f); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11270Sorry, I reduced the repro case to much. Here is the actual repro case I had first: struct netvar(T) { T value; alias value this; void opAssign(T newVal){ value = newVal; } } class Foo { netvar!float f; this(float f) { this.f = f; } } void main(string[] args) { new Foo(2.0f); }Ah, this is an expected behavior that has been introduced by fixing bug 9665. With git-head, compiler tries to rewrite `this.f = f;` to the field initialization. Possible modifications: 1. Rewrite this.f = f; to this.f = netvar!float(f); It will initialize the Foo.f by the struct literal. 2. Add a constructor this(T); in netbar struct to accept a T value as a valid initializer. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11270 PDT --- Thanks for the suggestions. I knew how to fix this, but I just wanted to confirm that this is indeed intended behavior and not a regression, because it used to work in all earlier compiler versions. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 15 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11270 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALIDThanks for the suggestions. I knew how to fix this, but I just wanted to confirm that this is indeed intended behavior and not a regression, because it used to work in all earlier compiler versions.It was the long standing bug. I'm glad to be able to fix it finally. Mark this issue as resolved invalid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 15 2013