[Issue 11270] [REG 2.064] Initialization of struct in constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 15 07:02:26 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11270
--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-15 07:02:24 PDT ---
(In reply to comment #2)
> 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);
> }
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: -------
More information about the Digitalmars-d-bugs
mailing list