Skip to content

A parameter is an immutable binding, and the consuming rebind applies to it (D220, #690) - #3450

Merged
ehartford merged 2 commits into
mainfrom
param-rebind
Nov 19, 2026
Merged

ehartford merged 2 commits into
mainfrom
param-rebind

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #690. Ruled by Eric (D220); spec v7.66 carries his words (§9.1, §29.8).

  • Assigning to a parameter is refused with an error that names both real fixes: var x = x for a working copy, or mut x: T to change the caller's variable.
  • var x = x works, for a parameter and for a local. A value with no destructor is consumed by a read in its own initializer, so let x = x + 1 is accepted too; let x = 2 is still refused, and so is a rebind while a view of the old binding is live.
  • In a loop or a branch the rebind is refused (four tests pin it, for locals and parameters): the old binding would come back after the block, or be read again on the next iteration.
  • The exception found the parameters' scope by comparing start indexes, which mistook a nested block of a function with no parameters for the body; it now finds it by position.

Battery green on the branch tip.

Eric Hartford added 2 commits November 18, 2026 16:36
@ehartford
ehartford merged commit 6dd7530 into main Nov 19, 2026
@ehartford
ehartford deleted the param-rebind branch November 19, 2026 00:58
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.

Parameter rebinding rejected despite mutability.md declaring parameters implicitly rebindable

1 participant