You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow a `mut` parameter of a Copy scalar type (Int/Bool/Float/Char, …) to be
reassigned inside the callee, with the new value written back to the caller
(call-by-reference, `&mut`). Non-Copy `mut` params stay non-reassignable.
The reg-VM already writes every `mut` param's final register back (effect-based
mut_args), so no reg-VM/native change is needed. Two frontend touch-points:
- analyzer/assign.rs: permit rebinding a `mut` Copy-scalar parameter (gated on
checks::local::is_copy_type_name); keep RS0311 for plain params and non-Copy
`mut` params.
- rust_lower/lowerer.rs: emit `(*pos)` on read and as assignment target for a
`mut` Copy-scalar param, since `mut T` already lowers to `&mut T`.
Adds pass fixture mut-scalar-writeback.rss (Int + Bool). Updates spec §5A and
the grammar comment, and ledger SH-018.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
format!("`{name}` is a parameter, not a reassignable local"),
367
-
"Parameters are not reassignable (even `mut` ones): a `mut` parameter's fields/elements may be updated, but the parameter binding itself can't be rebound. Bind a `let mut` local instead."
379
+
"Parameters are not reassignable (except a `mut` Copy-scalar one, which is written back to the caller): a non-Copy `mut` parameter's fields/elements may be updated, but the parameter binding itself can't be rebound. Bind a `let mut` local instead."
0 commit comments