diff --git a/CHANGELOG.md b/CHANGELOG.md index f74ea72aee..7435bcfcbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,19 @@ The sections do not signal obligations; the prefixes do. ## Unreleased +### Changed + +- The variables of a scope (`define`/`in`) are visible only within its `in`. + Pointers outside the scope, such as later members of an enclosing group, do + not see them, and a variable defined with an outer variable's identifier + shadows it only within `in`. The description now says so ([#318]). + - Schemas: **ethdebug/format/pointer/collection/scope** + - Producers: no change needed. The text states the existing meaning; solc's + storage templates already depend on it. + - Consumers: required: a consumer that keeps a scope's variables after its + `in` must discard them there. `@ethdebug/pointers` does so from + [#317]. + ## 0.1.0-draft.1 — 2026-10-03 ### Added @@ -660,3 +673,5 @@ First published version of the specification. [#303]: https://github.com/ethdebug/format/pull/303 [#305]: https://github.com/ethdebug/format/pull/305 [#309]: https://github.com/ethdebug/format/pull/309 +[#317]: https://github.com/ethdebug/format/pull/317 +[#318]: https://github.com/ethdebug/format/pull/318 diff --git a/packages/web/docs/core-schemas/pointers/collections.mdx b/packages/web/docs/core-schemas/pointers/collections.mdx index 1dec6ed79c..689e4bbdf3 100644 --- a/packages/web/docs/core-schemas/pointers/collections.mdx +++ b/packages/web/docs/core-schemas/pointers/collections.mdx @@ -85,7 +85,9 @@ evaluates to a non-zero value. ## Scope A **scope** defines variables that can be used in a nested pointer. Variables -are evaluated in order, so later variables can reference earlier ones. +are evaluated in order, so later variables can reference earlier ones. They are +visible only within `in`: pointers outside the scope, such as later members of +an enclosing group, do not see them. Scopes help break complex pointer definitions into readable steps. For examples combining scopes with keccak256 for storage slot computation, see the diff --git a/schemas/pointer/collection/scope.schema.yaml b/schemas/pointer/collection/scope.schema.yaml index d175bc01f1..f5622647fa 100644 --- a/schemas/pointer/collection/scope.schema.yaml +++ b/schemas/pointer/collection/scope.schema.yaml @@ -10,6 +10,11 @@ description: | expression by identifier. Variables are specified **in order**, so that later appearing variables may reference earlier ones in the same object. + The variables are visible only within `in`. Pointers outside this scope + do not see them: later members of an enclosing group, for example, see + only the variables of their own enclosing scopes. A variable defined here + with the same identifier as an outer variable shadows it within `in`. + type: object properties: