Skip to content

pointers: allow regions named like object properties - #316

Merged
gnidan merged 1 commit into
mainfrom
pointers-region-named-length
Oct 3, 2026
Merged

gnidan merged 1 commit into
mainfrom
pointers-region-named-length

Conversation

@gnidan

@gnidan gnidan commented Oct 3, 2026

Copy link
Copy Markdown
Member

dereference threw TypeError: Cannot redefine property: length when a pointer yielded a region named length. solc's ethdebug pointer templates (argotorg/solidity#16990) do this for a top-level dynamic array: the template yields regions named length and item. Inside a mapping it only worked because a yields rename turns length into value-length.

The cause is in cursor.view. It builds regions as an array-like and also defines each region name as a property of it, so a region named length collides with the array's own length. Names such as named and lookup would collide the same way. The bookkeeping maps there, and the regions and variables maps used while generating regions, were plain objects, so constructor or toString resolved to inherited functions (named[name].push is not a function), and __proto__ was never stored as a key.

The maps now have no prototype, and the yields rename lookup checks own properties. A region whose name would shadow an existing property of regions is still reachable through regions.lookup and regions.named, but is no longer also exposed as a property of the array. Names that do not collide keep working as before.

Tests cover length, constructor, __proto__ and toString as region names, both referenced from a later region and renamed with yields.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-03 14:15 UTC

@gnidan
gnidan merged commit 5f94285 into main Oct 3, 2026
7 checks passed
@gnidan
gnidan deleted the pointers-region-named-length branch October 3, 2026 14:11
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