[Issue 11984] not using opAssign when declaration in different scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 25 09:34:14 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11984



--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2014-01-25 09:34:11 PST ---
This is an intended behavior. In short, field assignment expression inside
constructor is specially translated to the field initialization.

https://d.puremagic.com/issues/show_bug.cgi?id=9665
http://dlang.org/class#field-init

In your code, S1!C is not directly initializable by C[] value, so

> class Broken {
> 
>   S1!(C[]) s1c;
> 
>   this () {
>       s1c = [new C()];
>   }
> }

Should be rewritten to:

    this () {
        s1c = S1!C([new C()]);
    }

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list