Skip to content

fixes #26050; preserve defer scope across when nimvm - #26067

Open
subotac wants to merge 1 commit into
nim-lang:develfrom
subotac:fix/defer-nimvm-scope
Open

fixes #26050; preserve defer scope across when nimvm#26067
subotac wants to merge 1 commit into
nim-lang:develfrom
subotac:fix/defer-nimvm-scope

Conversation

@subotac

@subotac subotac commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #26050.

Preserve the enclosing statement-list tail when lifting defer from when nimvm branches, so the deferred action runs at the end of the lexical scope in both native and VM execution.

Adds native and VM regression coverage.

@Araq

Araq commented Aug 3, 2026

Copy link
Copy Markdown
Member

Adhoc logic, there's got to be a better way.

@subotac
subotac force-pushed the fix/defer-nimvm-scope branch from d847d7e to 7fd6b61 Compare August 3, 2026 14:06
@subotac

subotac commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Agreed — I reworked this to split the same-scope control flow around each defer, including through retained when nimvm nodes. The conditional portions stay under when nimvm, while the surrounding continuation remains shared. This avoids copying the outer tail into both branches and also covers nested and multiple defers.

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.

defer in else branch of when nimvm has too-narrow scope

2 participants