[Issue 11346] [2.064 beta] field initializing not allowed in loops or after labels

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 25 00:50:41 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11346



--- Comment #6 from rswhite4 at googlemail.com 2013-10-25 00:50:39 PDT ---
To describe my viewpoint somewhat closer:

----
if (Primitive.Target.Vertex & trg)
    this._targetIds[Primitive.Target.Vertex] = ids++; [1]
if (Primitive.Target.Color & trg)
    this._targetIds[Primitive.Target.Color] = ids++; [2]
if (Primitive.Target.TexCoords & trg)
    this._targetIds[Primitive.Target.TexCoords] = ids++; [2]
----

[1] is allowed because the compiler things, that is the first assignment for
_targetIds. But that is _no_ real assignment. 
A real assigment would be something like that: this._targetIds = ...;
It is an index assignment, so the AA is probably not fully initialized.

[2] and [3] are rejected, because the compiler thinks, that this are multiple
assignments. But that is plain worng. That are also index assignments to
initialize my AA.

Same thing for normal arrays.
A assignment would be arr = [1, 2, 3];
But the operator ~= is a concatenation to initialize my array.

IMO we should distinguish this. That would retain your type safety and get rid
of the annoying limitation.

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