simendsjo:
Shouldn't T[char[]] be disallowed, and have to be written as
T[immutable(char)[]] instead of a silent rewrite?
Of course. I have a Bugzilla issue on this.
Bye,
bearophile
[immutable(char)[]] instead of a silent rewrite?
alias long[char[]] AA;
// key automatically changed to const(char)[]
static assert(is(AA == long[const(char)[]]));
AA aa;
aa[a] = 10;
// error - have to use immutable keys
aa[b.dup] = 11;
By design, the problem is things like
..?)
Shouldn't T[char[]] be disallowed, and have to be written as
T[immutable(char)[]] instead of a silent rewrite?
alias long[char[]] AA;
// key automatically changed to const(char)[]
static assert(is(AA == long[const(char)[]]));
AA aa;
aa[a] = 10;
// error - have
[]] be disallowed, and have to be written as
T[immutable(char)[]] instead of a silent rewrite?
alias long[char[]] AA;
// key automatically changed to const(char)[]
static assert(is(AA == long[const(char)[]]));
AA aa;
aa[a] = 10;
// error - have to use immutable keys
aa[b.dup] = 11
automatically convert to const
(right...?)
Shouldn't T[char[]] be disallowed, and have to be written as
T[immutable(char)[]] instead of a silent rewrite?
alias long[char[]] AA;
// key automatically changed to const(char)[]
static assert(is(AA == long[const(char)[]]));
AA aa
Andrew Wiley:
If the compiler is basically going to disallow using the AA as
anything but a long[string], it should really disallow declaring
anything with a mutable key type. Disallowing mutable keys at that
assignment site but allowing them in the type is confusing.
Two related bug
On Tue, Jan 3, 2012 at 4:20 PM, bearophile bearophileh...@lycos.com wrote:
Andrew Wiley:
If the compiler is basically going to disallow using the AA as
anything but a long[string], it should really disallow declaring
anything with a mutable key type. Disallowing mutable keys at that
Andrew Wiley:
Some consequences of actually changing this:
- This breaks D1 compatibility of AAs across the board because
immutable simply didn't exist then
D1 compatibility will stop being a problem in some time :-)
- Significant D2 code breakage as well
It's essentially wrong code,