Conversation
… in QuotationSimplifier When a 'let mutable v = ...' variable is used inside a lambda in a quotation used by a generated type provider, the TPSDK emits IL that copies the variable value into a closure field at the time the lambda is created. Mutations inside the lambda (or visible to it via VarSet) are not reflected back to the outer scope, causing incorrect behavior. This fix implements the approach suggested in the issue: detect when a mutable let-bound variable is captured by any lambda in its scope (via isCapturedByLambda), and promote it to a ref cell (via promoteMutableToRef). The transformation: let mutable v = init in body => The previously-skipped test 'lambdas - failing' in GeneratedCodeTests.fs now passes, confirming that nested closures correctly share mutable state. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Feb 26, 2026
Closed
dsyme
approved these changes
Feb 26, 2026
dsyme
pushed a commit
that referenced
this pull request
Mar 7, 2026
🤖 *This PR was created by Repo Assist, an automated AI assistant.* Prepares the RELEASE_NOTES.md for version **8.3.0** — a minor release capturing significant improvements merged since 8.2.0 (February 24). ## Changes since 8.2.0 | Type | PR | Description | |------|----|-------------| | 🐛 Bug fix | #432 | Fix custom attributes on nested erased types | | 🐛 Bug fix | #458 | Fix `GetNestedType` on `TypeSymbol`/`ProvidedTypeSymbol` for generic provided types | | 🐛 Bug fix | #459 | Fix mutable variable captures in `QuotationSimplifier` — promote to ref cells | | ⚡ Performance | #443 | Memoize `transType` in `AssemblyCompiler` to reduce redundant type translation | | ⚡ Performance | #457 | Cache `transTypeRef` and `transMethRef` in assembly compiler | | ✨ Feature | #428 | New warning when all static parameters in a type provider are optional | | 📚 Docs | #455 | Documentation guide overhaul | | 🧪 Tests | #442 | Add coverage tests and Coverage build target | | 🔧 Toolchain | #431 | Update to .NET 8 SDK and toolchain | This is a minor version bump (8.2.0 → 8.3.0) due to the new feature (#428) and significant improvements. If preferred, a patch release (8.2.1) is also reasonable given the emphasis on bug fixes. ## Test Status This PR only modifies RELEASE_NOTES.md. The build/test status for the underlying changes is tracked in the individual PRs listed above (all passed CI before merging). --- *To release: merge this PR, then tag `v8.3.0` and publish the NuGet package via the existing build pipeline.* > Generated by [Repo Assist](https://github.com/fsprojects/FSharp.TypeProviders.SDK/actions/runs/22448247879) > > To install this [agentic workflow](https://github.com/githubnext/agentics/tree/afb00b92a9514fee9a14c583f059a03d05738f70/workflows/repo-assist.md), run > ``` > gh aw add githubnext/agentics@afb00b9 > ``` <!-- gh-aw-agentic-workflow: Repo Assist, engine: copilot, id: 22448247879, workflow_id: repo-assist, run: https://github.com/fsprojects/FSharp.TypeProviders.SDK/actions/runs/22448247879 --> <!-- gh-aw-workflow-id: repo-assist --> --------- Co-authored-by: Repo Assist <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant. Fixes #323.
Problem
When a
let mutable v = ...variable is captured by a lambda in a quotation used by a generated type provider, the TPSDK IL emitter copies the variable's value into a closure field at lambda-creation time. Mutations inside the closure do not propagate back to the outer scope (and vice versa), causing incorrect runtime behaviour: