Skip to content

fix(all): copy mutable struct records by value - #5270

Merged
MangelMaxime merged 2 commits into
mainfrom
fix/struct-copy-update-mutable
Nov 11, 2026
Merged

MangelMaxime merged 2 commits into
mainfrom
fix/struct-copy-update-mutable

Conversation

@MangelMaxime

Copy link
Copy Markdown
Member

Fixes #5253.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Python Type Checking Results (Pyright)

Metric Value
Total errors 33
Files with errors 4
Excluded files 4
New errors ✅ No
Excluded files with errors (4 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_hash_set.py 18 Excluded
temp/tests/Python/test_applicative.py 11 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 2 Excluded

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Caching the source before update expressions run can copy stale unchanged fields when a mutable struct is reassigned during an update, requiring deferred dereferencing and a regression test.

1 open issue
What changed in this PR

This PR addresses #5253, where copy-and-update expressions on mutable struct records lose unchanged fields. It adjusts the shared F# transformation stage and adds regression tests across five targets.

Changes:

  • Unwrap addresses for compiler-generated record-copy bindings and field reads on non-Rust targets.
  • Test preservation of unchanged fields when copying mutable struct locals.
  • Add mutable-field and module-level source coverage in selected target suites.
File Description
tests/​Rust/​tests/​src/​RecordTests.fs Adds mutable struct copy-and-update coverage.
tests/​Python/​TestRecordType.fs Tests local, mutable-field, and module-level cases.
tests/​Js/​Main/​RecordTypeTests.fs Tests local, mutable-field, and module-level cases.
tests/​Dart/​src/​RecordTests.fs Tests mutable locals and records with mutable fields.
tests/​Beam/​RecordTests.fs Tests mutable locals and records with mutable fields.
src/​Fable.Transforms/​FSharp2Fable.fs Changes address handling for record-copy bindings and field reads.

Review effort: Balanced

Comment thread src/Fable.Transforms/FSharp2Fable.fs Resolved
@MangelMaxime
MangelMaxime marked this pull request as ready for review November 11, 2026 17:47
@MangelMaxime
MangelMaxime merged commit f9657ad into main Nov 11, 2026
36 checks passed
@MangelMaxime
MangelMaxime deleted the fix/struct-copy-update-mutable branch November 11, 2026 17:48
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.

Copy-and-update of a let mutable struct record loses the unchanged fields

2 participants