mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 12:40:11 +03:00
This commit is contained in:
parent
bb25d82a3b
commit
1b34fea478
2 changed files with 24 additions and 3 deletions
|
@ -3266,9 +3266,19 @@ Type merge(Type type)
|
|||
|
||||
case Tsarray:
|
||||
// prevents generating the mangle if the array dim is not yet known
|
||||
if (!type.isTypeSArray().dim.isIntegerExp())
|
||||
return type;
|
||||
goto default;
|
||||
if (auto ie = type.isTypeSArray().dim.isIntegerExp())
|
||||
{
|
||||
// After TypeSemantic, the length is always converted to size_t, but the parser
|
||||
// usually generates regular integer types (e.g. in cast(const ubyte[2])) which
|
||||
// it may try to merge, which then leads to failing implicit conversions as 2LU != 2
|
||||
// according to Expression.equals. Only merge array types with size_t lengths for now.
|
||||
// https://github.com/dlang/dmd/issues/21179
|
||||
if (ie.type != Type.tsize_t)
|
||||
return type;
|
||||
|
||||
goto default;
|
||||
}
|
||||
return type;
|
||||
|
||||
case Tenum:
|
||||
break;
|
||||
|
|
11
compiler/test/compilable/test21179.d
Normal file
11
compiler/test/compilable/test21179.d
Normal file
|
@ -0,0 +1,11 @@
|
|||
// https://github.com/dlang/dmd/issues/21179
|
||||
|
||||
void bigEndianToNative(ubyte[2] a) {}
|
||||
|
||||
void main()
|
||||
{
|
||||
ubyte[] arr;
|
||||
const ubyte[2] bytes;
|
||||
bigEndianToNative(bytes);
|
||||
auto b = cast(const ubyte[2][]) arr;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue