Skip to content

Run field and base destructors after a return in a destructor - #2632

Merged
bfiete merged 1 commit into
beefytech:masterfrom
M0n7y5:fix-dtor-return-field-dtors
Dec 1, 2026
Merged

bfiete merged 1 commit into
beefytech:masterfrom
M0n7y5:fix-dtor-return-field-dtors

Conversation

@M0n7y5

@M0n7y5 M0n7y5 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor
  • A return in ~this skipped the field destructors and the base ~this, so their objects leaked. A return as the last statement of the body or of a field destructor block made LLVM abort the build.
  • A return now ends only the destructor body or field destructor block, and the rest of the destructor runs as on fall through. A defer:: or scope:: after the return runs only when reached.
  • Behaviour change: field and base destructors now run after an early return, so a destructor that returns early on an uninitialized object also deletes its fields.

Tests: Objects.TestDtorReturn in IDEHelper/Tests/src/Objects.bf. Compiler tests and the IDE test suite pass on Linux and Windows.

@bfiete
bfiete merged commit b7745e9 into beefytech:master Dec 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants