diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index 9a57824d9f7f..c69ac369ab39 100644 --- a/src/dmd/expressionsem.d +++ b/src/dmd/expressionsem.d @@ -1912,7 +1912,8 @@ private bool functionParameters(const ref Loc loc, Scope* sc, : p.type; const hasCopyCtor = (arg.type.ty == Tstruct) && (cast(TypeStruct)arg.type).sym.hasCopyCtor; - if (!(hasCopyCtor || tprm.equals(arg.type))) + const typesMatch = arg.type.mutableOf().unSharedOf().equals(tprm.mutableOf().unSharedOf()); + if (!((hasCopyCtor && typesMatch) || tprm.equals(arg.type))) { //printf("arg.type = %s, p.type = %s\n", arg.type.toChars(), p.type.toChars()); arg = arg.implicitCastTo(sc, tprm); diff --git a/test/runnable/test20025.d b/test/runnable/test20025.d new file mode 100644 index 000000000000..42f8257ddb8f --- /dev/null +++ b/test/runnable/test20025.d @@ -0,0 +1,27 @@ +// https://issues.dlang.org/show_bug.cgi?id=20025 +/* +TEST_OUTPUT: +--- +--- +*/ + +struct B +{ + static int value = 77; + alias value this; + + this(ref return scope inout B rhs) inout { } +} + +void test(int x) +{ + assert(x == 77); +} + +int main() +{ + B b; + test(b); + + return 0; +}