dmd icon indicating copy to clipboard operation
dmd copied to clipboard

[REG master] Array concatenation with inout compile error

Open tim-dlang opened this issue 3 months ago • 3 comments

The following code compiled with DMD 2.111:

inout(int[]) test1(inout(int[]) a, int b)
{
    return a ~ b;
}
inout(int[]) test2(inout(int[]) a, inout(int[]) b)
{
    return a ~ b;
}
void main()
{
    test1([1], 2);
    test2([1], [2]);
}

With DMD master it results in the following compile error instead:

./generated/linux/release/64/../../../../druntime/import/core/internal/array/casting.d(81): Error: `inout` on `return` means `inout` must be on a parameter as well for `pure @nogc @trusted inout(int)[](return scope void[] from)`
TTo[] __ArrayCast(TFrom, TTo)(return scope TFrom[] from) @nogc pure @trusted
      ^
./generated/linux/release/64/../../../../druntime/import/core/internal/array/concatenation.d(47): Error: template instance `core.internal.array.casting.__ArrayCast!(void, inout(int))` error instantiating
    res = cast(Tret) __arrayAlloc!(UnqT)(elemSize * totalLen);
          ^
testinoutconcat.d(3):        instantiated from here: `_d_arraycatnTX!(inout(int)[], inout(int[]), inout(int))`
    return a ~ b;
             ^
testinoutconcat.d(7): Error: template instance `core.internal.array.concatenation._d_arraycatnTX!(inout(int)[], inout(int[]), inout(int[]))` error instantiating
    return a ~ b;
             ^

tim-dlang avatar Sep 21 '25 12:09 tim-dlang

cc @Albert24GG

thewilsonator avatar Sep 21 '25 12:09 thewilsonator

Looks like this may be fixed now.

ntrel avatar Sep 26 '25 17:09 ntrel

Yes, it works now. The dlang-bot still only mentions bugzilla issues. I'm not sure how github issues should be mentioned, so they are automatically closed and will be part of the changelog.

tim-dlang avatar Sep 27 '25 13:09 tim-dlang