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