Skip to content

testsuite batch97: prefix readonly-through-nameref declare error - #308

Merged
brianjfox merged 1 commit into
mainfrom
fix/testsuite-batch97
Jul 25, 2026
Merged

testsuite batch97: prefix readonly-through-nameref declare error#308
brianjfox merged 1 commit into
mainfrom
fix/testsuite-batch97

Conversation

@brianjfox

Copy link
Copy Markdown
Owner

Batch 97 — nameref test 237 → 235. Extends batch94's declare readonly-prefix conformance to the nameref case.

declare/typeset/local prefix a readonly-assignment failure with the builtin name, but only did so for a direct readonly variable. Assigning through a nameref to a readonly target fell through to Shell::set and printed the bare target name:

declare -r foo0=x; declare -n ref=foo0; declare ref=X
  bash:  declare: ref: readonly variable
  gnash: foo0: readonly variable      # bare, and leaks the target name

Now the nameref is resolved for the readonly test but the diagnostic reports the name as written (ref), matching bash. This also collapses the readonly empty-nameref case (typeset -n r; typeset -r r; typeset r=x) from gnash's bare-line-plus-prefixed-line to the single prefixed message bash prints.

ctest 22/22, run_diff all 234 scripts match bash. No regressions (varenv, declare unchanged).

The deeper nameref17 remainders (typeset +n/+r on a readonly nameref, function-scope readonly namerefs) and the quoted-vs-unquoted declare -n a=(...) compound-assignment distinction remain — the latter needs parse-time compound-assignment tracking gnash doesn't preserve in a builtin's argv.

…arget

declare/typeset/local already prefixed a readonly-assignment failure with
the builtin name, but only for a direct readonly variable; assigning
through a nameref to a readonly target (`declare -r foo0=x; declare -n
ref=foo0; declare ref=X') fell through to Shell::set and printed the bare
target name (`foo0: readonly variable').  Resolve the nameref for the
readonly test but report the name as written, matching bash's `declare:
ref: readonly variable'.  This also collapses the readonly empty-nameref
case (`typeset -n r; typeset -r r; typeset r=x') to the single prefixed
message bash prints instead of a bare line plus a prefixed one.
@brianjfox
brianjfox merged commit 3987c5f into main Jul 25, 2026
1 check passed
@brianjfox
brianjfox deleted the fix/testsuite-batch97 branch July 25, 2026 18:44
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.

1 participant