Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4541,7 +4541,8 @@ private bool functionParameters(Loc loc, Scope* sc,
{
// Look for misaligned pointer, etc., in @safe mode
err |= checkUnsafeAccess(sc, arg, false, true);
err |= checkDefCtor(arg.loc, t); // t must be default constructible
if (!t.isClassHandle())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!t.isClassHandle())
if (!t.baseElemOf().isTypeClass())

So it also works with enums and static arrays

enum E : Client { a = null }
void sinkArr(out Client[3] r) {}
void sinkEnumArr(out E[3] r) {}

err |= checkDefCtor(arg.loc, t); // t must be default constructible
}
arg = arg.toLvalue(sc, "create `out` parameter from");
}
Expand Down
9 changes: 9 additions & 0 deletions compiler/test/compilable/class_struct_disable_default.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://github.com/dlang/dmd/issues/23392
struct Parser { @disable this(); this(int) {} }
class Client { Parser parser; this() { parser = Parser(0); } }
void sink(out Client r) {}
void main() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compilable test should not contain a main, rename test.

Client c;
// passing c just sets it to null, so no @disable error needed
sink(c);
}
Loading