[Issue 9186] Manifest constant can violate const correctness restrictions when empty

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 21 01:52:16 PST 2012


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



--- Comment #5 from monarchdodra at gmail.com 2012-12-21 01:52:11 PST ---
(In reply to comment #3)
> This is not a type system problem.
> 
> All manifest constants, which declared by `enum` and T.init, make literal
> expressions in the places where they used.
> 
> alias T = string[];
> enum T strs = [[]];
> foo(T.init);  // same as foo(null);
> foo(strs);    // same as foo([[]]);
> 
> And, empty array literal and null literal can ignore their type qualifiers in
> constant-folding process, because they have no references to qualified values.

I see your point, but I argue there is a difference between a "type-less"
literal and an "empty" literal.

(T[]).init, while empty, does carry a type, and it should be
preserved/propagated.

Heck, proof that a non-empty literal can have "no type":
"[[]]" is *not* empty. It is a type-less slice which carries a single empty
typeless slice. Yet you can still write "int[][] a = [[]];"

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