Repository navigation
fix(declare-local): skip readonly refusal when the operand creates a fresh local - #3610
Merged
Merged
Conversation
…fresh local A local/declare operand that creates a FRESH local inside a function binds the new mutable instance — an outer-scope readonly mark on the same name must not fire (GNU make_local_variable, declare.def:929+ / variables.c:5524+). The nested_readonly check consulted the flat READONLY_VARS name mark without regard to locally_scoped, so 'local x=(7 8 9)' inside a caller holding 'local -r x' spuriously reported 'x: readonly variable' (while still binding). Also gate local_context on the declare family: export/readonly operands always bind the inherited (global) variable (setattr.def:240-268), so the non-localizing readonly refusal still fires for them — verified against GNU 5.3.20 (export/declare -g on a global readonly inside a function: diagnostic, then the body continues). Same-scope re-local on a readonly local still refuses; an inner-scope readonly mark shadowed by a fresh local stays scoped to its instance. Fixes #3609. Refs #2666 (varenv19.sub ccc). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿:
F 点:无。 合入:
未跑/VOID 的腿:无。 |
This was referenced Nov 16, 2026
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.
Summary
A
local/declareoperand that creates a FRESH local inside a function binds the new mutable instance — an outer-scope readonly mark on the same name must not fire (GNUmake_local_variable,declare.def:929+/variables.c:5524+). Thenested_readonlycheck consulted the flatREADONLY_VARSname mark without regard tolocally_scoped, solocal x=(7 8 9)inside a caller holdinglocal -r xspuriously reportedx: readonly variable(while still binding).local_contextis also gated on the declare family:export/readonlyoperands always bind the inherited global (setattr.def:240-268), so their readonly refusal still fires — verified against GNU 5.3.20 on 4 probe shapes (fresh-local shadow / inner mutable shadow / export / declare -g on a global readonly), all byte-identical.5 new pins in
tests/issue3609_local_readonly_shadow.rs, all green; adjacent declare/readonly/local regression batches green.Fixes #3609. Refs #2666.