Bug 20032 – ImmutableOf!char[] The result is incorrect.

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2019-07-07T03:57:47Z
Last change time
2019-07-07T14:02:32Z
Assigned to
No Owner
Creator
shove

Comments

Comment #0 by shove — 2019-07-07T03:57:47Z
When the template parameter is char: alias A = char[]; alias ImmuTypeA = ImmutableOf!A; pragma(msg, ImmuTypeA); // -> immutable(string), Should be: immutable(char[]) alias B = immutable (char) []; alias ImmuTypeB = ImmutableOf!B; pragma(msg, ImmuTypeB); // -> immutable(string), OK! This incorrect does not exist when the template parameter is int: alias A = int[]; alias ImmuTypeA = ImmutableOf!A; pragma(msg, ImmuTypeA); // -> immutable(int[]), OK! alias B = immutable (int) []; alias ImmuTypeB = ImmutableOf!B; pragma(msg, ImmuTypeB); // -> immutable(int[]), OK!
Comment #1 by ag0aep6g — 2019-07-07T10:59:20Z
(In reply to shove from comment #0) > alias A = char[]; > alias ImmuTypeA = ImmutableOf!A; > pragma(msg, ImmuTypeA); // -> immutable(string), Should be: > immutable(char[]) immutable(string) and immutable(char[]) are the same type. string = immutable(char)[] immutable(string) = immutable(immutable(char)[]) = immutable(char[]) I'm closing this issue as invalid. Feel free reopen if I'm missing the point.
Comment #2 by shove — 2019-07-07T14:02:32Z
(In reply to ag0aep6g from comment #1) > (In reply to shove from comment #0) > > alias A = char[]; > > alias ImmuTypeA = ImmutableOf!A; > > pragma(msg, ImmuTypeA); // -> immutable(string), Should be: > > immutable(char[]) > > immutable(string) and immutable(char[]) are the same type. > > string = immutable(char)[] > immutable(string) = immutable(immutable(char)[]) = immutable(char[]) > > I'm closing this issue as invalid. Feel free reopen if I'm missing the point. Thanks. It's not really a bug. I don't need to reopen it. They are really the same type, Usually no problem. But in some cases, string comparison through typeid(…) can cause trouble, such as the implementation of Variant: https://github.com/dlang/phobos/blob/master/std/variant.d#L299 https://github.com/dlang/phobos/blob/master/std/variant.d#L320