Skip to content

format: allow identifiers to start with $ - #325

Merged
gnidan merged 2 commits into
mainfrom
architect-dollar-identifiers
Oct 8, 2026
Merged

gnidan merged 2 commits into
mainfrom
architect-dollar-identifiers

Conversation

@gnidan

@gnidan gnidan commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Solidity allows a name to start with $, and a compiler wants to use source names as they are in pointer output (region, variable and template names). ethdebug/format/pointer/identifier now allows a leading $, so a name such as $balance needs no renaming. A leading ~ stays forbidden.

This splits out from #323, which switched the format's own terms to ~. That switch removed the collision a leading $ would otherwise cause, such as "$wordsize" being both a variable name and the format constant.

For producers, this is optional: a name may now start with $. bugc's names never start with $, so its output does not change. For consumers, it is required: a string that starts with $ can now be a name ("$wordsize" is a variable, { ".offset": "$this" } looks up a region named $this), so a consumer must accept the wider identifier pattern.

The reference implementation follows. Pointer.isIdentifier in @ethdebug/format accepts a leading $, and @ethdebug/pointers resolves $ names for variables, regions and templates. Its hint for an old $ term moves to the failure paths where such a name now lands: an unknown variable, or a region that is not found. The Unreleased changelog entries say the same.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-08 00:47 UTC

@gnidan
gnidan force-pushed the architect-tilde-sigil branch from cbf1ea0 to 73691fa Compare October 8, 2026 00:10
@gnidan
gnidan force-pushed the architect-dollar-identifiers branch from a1370ad to 35441b4 Compare October 8, 2026 00:13
@gnidan
gnidan marked this pull request as ready for review October 8, 2026 00:19
Base automatically changed from architect-tilde-sigil to main October 8, 2026 00:27
gnidan added 2 commits October 7, 2026 20:27
Solidity allows a name to start with $, so admit one as a pointer
identifier. Now that the format's own terms use ~, a name such as
$wordsize or $this is a variable or region name and cannot be read as
a format term.

@ethdebug/pointers resolves such names, and its hint for an old $ term
moves to the failure paths where a $ name now lands: an unknown
variable or a region that is not found.
@gnidan
gnidan force-pushed the architect-dollar-identifiers branch from 35441b4 to 4901010 Compare October 8, 2026 00:29
@gnidan
gnidan merged commit 399aab7 into main Oct 8, 2026
8 checks passed
@gnidan
gnidan deleted the architect-dollar-identifiers branch October 8, 2026 00:42
djolertrk added a commit to walnuthq/soldb that referenced this pull request Oct 8, 2026
ethdebug/format 0.1.0-draft.2 spells its pointer expression terms with
`~` instead of `$` (ethdebug/format#323) and lets identifiers start with
`$` (ethdebug/format#325), and solc follows it. Read `~sum`, `~read`,
`~wordsize`, `~this` and the other terms, and accept names starting with
`$`, so a struct member such as `$member` is found as it is.

Released compilers still write `$sum` and the like, so the `$` spelling
is still read as the term wherever a name cannot be meant: as an
expression key, and as `$wordsize` and `$this`, which no compiler names a
variable or a region. The fixture is regenerated with the stamp and the
`~` terms, and the pointer lit test accepts either spelling.
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