[Issue 6408] string[].init gives a wrong type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 30 12:03:17 PDT 2011


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



--- Comment #3 from kennytm at gmail.com 2011-07-30 12:03:14 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > Apparently DMD shouldn't accept string[].init at all, e.g. int[].init is a
> > parser error:
> 
> Isn't it better to modify DMD to accept both string[].init and int[].init, and
> return the correct results in both cases?
> 
> Because the alternative idiom to create an empty array is to use cast(int[])[],
> and it's better to avoid casts where possible.

You could also just add a pair of parenthesis:

    (string[]).init
    (int[]).init

And (X[]).init returns 'null', not '[]'.


I'm not sure about allowing `S[].prop`. If this is allowed, we should also
allow `S[3].prop` and `S[T].prop` and maybe even `S*.prop`. Maybe let's have a
rejects-valid or enhancement request.

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