[Issue 11744] static array members should be individually initializable

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 15 00:39:22 PST 2013


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



--- Comment #2 from monarchdodra at gmail.com 2013-12-15 00:39:19 PST ---
(In reply to comment #1)
> (In reply to comment #0)
> > Not sure if actual Bug or ER.
> 
> This is intended behavior, so this should be marked as enhancement.

Enhancement works for me.

> This behavior is introduced by:
> Issue 9665 - Structure constant members can not be initialized if have opAssign

Yes. That is very good behavior, thank you.

> Related regressions which they were rejected:
> Issue 11258 - Static field access problem
> Issue 11343 - [2.064 beta] Error: multiple field initialization
> Issue 11346 - [2.064 beta] field initializing not allowed in loops or after
> labels

I think these mostly asked for the ability to initialized the same variable
multiple times (which I also think is wrong).

I'm asking for the compiler to try to view static arrays as a aggregate of
values:
You can either initialize the entire array at once (in which case, the entire
array would be considered initialized, as well as each member), or each element
at once, in which case each element would be initialized individually 1 by 1.

Use cases:

this(int)
{
        value[0] = s; //init
        value[1] = s; //init

        value[0] = s; //assign
}

this(int)
{
        value = s; //init all
        value[0] = s; //assign
}

this(int)
{
        value[0] = s; //init

        //value already written to
        value = s; //assign to all
        value[1] = s; //assign
}

-- 
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