Bug 9604 – typeof emits wrong common type with immutable type

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-27T03:21:04Z
Last change time
2024-12-13T18:04:18Z
Assigned to
No Owner
Creator
Jakob Ovrum
Moved to GitHub: dmd#17574 →

Comments

Comment #0 by jakobovrum — 2013-02-27T03:21:04Z
--- import std.range; void main() { immutable(ubyte)[] imm; ubyte[] mut; auto c = chain(imm, mut); pragma(msg, ElementType!(typeof(c))); } --- Output: --- int --- As far as I can tell, the element type should be some permutation of ubyte, like const(ubyte), not int.
Comment #1 by andrej.mitrovich — 2013-02-27T15:40:17Z
The problem is shown when using CommonType: import std.traits; import std.typetuple; void main() { alias TypeTuple!(immutable(ubyte), ubyte) T; pragma(msg, CommonType!T); // int } This is a compiler bug. Test-case: void main() { alias IB = immutable(byte); pragma(msg, typeof(true ? byte.init : byte.init)); // byte pragma(msg, typeof(true ? IB.init : byte.init)); // int } Also another parser bug was found (I'll file this separately): void main() { auto x = immutable(byte).init; } test.d(3): Error: (arguments) expected following immutable(byte) test.d(3): Error: semicolon expected following auto declaration, not '.'
Comment #2 by andrej.mitrovich — 2013-02-27T15:42:57Z
(In reply to comment #1) > Also another parser bug was found (I'll file this separately): Filed as Issue 9613.
Comment #3 by schveiguy — 2020-08-10T12:40:40Z
This has nothing to do with chain or arrays, BTW: ubyte b; immutable ubyte b2; auto x = true ? b : b2; static assert(typeof(x) == int);
Comment #4 by robert.schadek — 2024-12-13T18:04:18Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17574 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB