Skip to content
Merged
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
1 change: 1 addition & 0 deletions compiler/src/dmd/semantic3.d
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ private extern(C++) final class Semantic3Visitor : Visitor
*/
Identifier id = Identifier.generateId("__o");
auto ts = new ThrowStatement(ctor.loc, new IdentifierExp(ctor.loc, id));
ts.internalThrow = true; // just rethrows the caught exception
auto handler = new CompoundStatement(ctor.loc, ss, ts);

auto ctch = new Catch(ctor.loc, getException(), id, handler);
Expand Down
4 changes: 3 additions & 1 deletion compiler/src/dmd/statementsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3644,7 +3644,9 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
//printf("ThrowStatement::semantic()\n");
if (throwSemantic(ts.loc, ts.exp, sc))
{
sc.ctorflow.orCSX(CSX.halt);
// internal rethrows shouldn't halt ctor flow
if (!ts.internalThrow)
sc.ctorflow.orCSX(CSX.halt);
result = ts;
}
else
Expand Down
11 changes: 11 additions & 0 deletions compiler/test/runnable/test23401.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// https://github.com/dlang/dmd/issues/23401

struct HasDtor { int x; ~this() {} }
class Base { int marker; this() { marker = 42; } }
class Derived : Base { HasDtor field; this() {} }

void main()
{
auto d = new Derived();
assert(d.marker == 42);
}
Loading