Skip to content

Commit 090b2d1

Browse files
committed
Temporary: Make sure no in parameter would be passed by ref with -preview=in
1 parent 46688ab commit 090b2d1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/dmd/typesem.d

+13
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,19 @@ extern(C++) Type typeSemantic(Type type, const ref Loc loc, Scope* sc)
15001500
if (!isPOD || target.preferPassByRef(t))
15011501
fparam.storageClass |= STC.ref_;
15021502
}
1503+
version (all)
1504+
{
1505+
if (!global.params.previewIn && (fparam.storageClass & (STC.in_ | STC.ref_)) == STC.in_)
1506+
{
1507+
auto ts = t.baseElemOf().isTypeStruct();
1508+
const isPOD = !ts || ts.sym.isPOD();
1509+
if (!isPOD || target.preferPassByRef(t))
1510+
{
1511+
.error(loc, "`in` parameter `%s` would be passed by reference with -preview=in", fparam.toChars());
1512+
errors = true;
1513+
}
1514+
}
1515+
}
15031516
}
15041517

15051518
// Now that we completed semantic for the argument types,

0 commit comments

Comments
 (0)