Skip to content

format: switch the pointer expression sigil from $ to ~ - #323

Merged
gnidan merged 4 commits into
mainfrom
architect-tilde-sigil
Oct 8, 2026
Merged

gnidan merged 4 commits into
mainfrom
architect-tilde-sigil

Conversation

@gnidan

@gnidan gnidan commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

The format's own terms inside pointer expressions now start with ~ instead of $. Solidity allows identifiers that start with $, and compilers want to use source names as they are in pointer output (region, variable and template names), so a source variable named $wordsize could collide with the format's "$wordsize" (#310).

Why ~: it cannot start an identifier in Solidity, Yul, Vyper or Fe, so no source name can collide with a format term. YAML reads ~sum: or - ~wordsize as plain strings (only a lone ~ is null), so the schemas and examples need no quoting. JSON Pointer has a defined escape for it (~0), so a $ref or an error path into an expression stays unambiguous.

The terms that change are the constants and references ~wordsize and ~this, and the operators ~sum, ~difference, ~product, ~quotient, ~remainder, ~read, ~keccak256, ~concat, ~wordsized and ~sized<N>. JSON Schema keywords ($ref, $id, $defs, $dynamicRef and so on) are unaffected.

ethdebug/format/pointer/identifier now says why a name must not start with ~; its pattern does not change. Allowing a leading $ in identifiers is split out into #325, which stacks on this PR and must merge after it.

This is breaking for producers and consumers, with no compatibility path. Producers must emit the ~ terms; the $ ones no longer validate. Consumers must read the ~ terms; the $ spellings are no longer format terms. The reference implementation moves with the schemas: the @ethdebug/format types and guards, the @ethdebug/pointers evaluator, and every pointer bugc emits (including the storage string and mapping entry templates and the calldata slice regions that landed since this PR opened) all use ~. The docs site and the Unreleased changelog entries follow; released entries are unchanged.

@ethdebug/pointers does not accept $ as a deprecated alias. Once #325 lets a name start with $, an alias would make "$wordsize" mean two things, which is the collision this change removes. When an invalid expression uses a $ spelling, the error suggests the ~ one.

The published @ethdebug/pointers@0.1.0-preview.1 depends on @ethdebug/format@^0.1.0-draft.1, a range that accepts the next draft, so it can be installed beside the new format and then misreads ~ data; the release must handle that.

Producers that emit pointer expressions must switch: solc (via Walnut's fork), Solar if it emits expressions, and bugc (done here). Until solc emits ~, the solc conformance tests translate a copy of solc's programs and resources to ~ before schema validation (withSolcTildeVocabulary in packages/conformance/test/conformance.test.ts, tracked in #324), next to the existing resources stamp workaround (#311). The libraries do not translate anything. SolDB still reads solc's original output. The translation fails with a "remove withSolcTildeVocabulary" message as soon as solc emits a ~ term.

Closes #310

@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:31 UTC

gnidan added 4 commits October 7, 2026 20:10
The format's own pointer vocabulary (~wordsize, ~this, ~sum, ~difference,
~product, ~quotient, ~remainder, ~read, ~keccak256, ~concat, ~wordsized,
~sized<N>) now uses the ~ sigil instead of $, so a source-language name
that starts with $ cannot collide with a format term. The identifier
schema now says why an identifier may not start with ~.

The schemas, the @ethdebug/format types and guards, the @ethdebug/pointers
evaluator, and bugc's pointer emission change together: each depends on
the others to build and pass its tests.
@gnidan
gnidan force-pushed the architect-tilde-sigil branch from cbf1ea0 to 73691fa Compare October 8, 2026 00:10
@gnidan
gnidan marked this pull request as ready for review October 8, 2026 00:19
@gnidan
gnidan merged commit d7cb421 into main Oct 8, 2026
8 checks passed
@gnidan
gnidan deleted the architect-tilde-sigil branch October 8, 2026 00:27
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.

Using $ prefix for pointer expression terms means they might collide with Solidity identifiers

1 participant