Skip to content

Comments

WIP :: Bugfix :: Fix closure capture and let-rec initialization codegen#19339

Draft
T-Gro wants to merge 1 commit intomainfrom
codegen/fix-closures-and-letrec
Draft

WIP :: Bugfix :: Fix closure capture and let-rec initialization codegen#19339
T-Gro wants to merge 1 commit intomainfrom
codegen/fix-closures-and-letrec

Conversation

@T-Gro
Copy link
Member

@T-Gro T-Gro commented Feb 20, 2026

Fixes invalid IL generated for closures and recursive bindings.

Also reorders let-rec bindings so lambda closures are allocated before non-lambda values that reference them, avoiding null dereferences at runtime.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

✅ No release notes required

@T-Gro T-Gro force-pushed the codegen/fix-closures-and-letrec branch 4 times, most recently from 457e616 to 78ae056 Compare February 20, 2026 17:23
Fix 3 codegen bugs in closure generation and initialization:
- #19068: Object expressions in struct types generate invalid IL with byref fields
- #17692: Duplicate parameter names in closure constructors
- #12384: let-rec mutual recursion initialization order for mixed lambda/value bindings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro force-pushed the codegen/fix-closures-and-letrec branch from 78ae056 to e2ddcab Compare February 20, 2026 18:50
Comment on lines +395 to +396
// Note: This is similar to ChooseFreeVarNames in IlxGen.fs but operates on
// IlxClosureFreeVar[] instead of string lists. Kept separate to avoid cross-file dependency.
Copy link
Member

Choose a reason for hiding this comment

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

Can this be extracted and unified somehow instead? If the logic is the same, we probably want to update it together in future, so producing duplicate code doesn't sound good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

2 participants