Skip to content

wasmprinter: print the identifier that outer aliases refer to - #2795

Open
jrandolf wants to merge 1 commit into
bytecodealliance:mainfrom
jrandolf:wasmprinter-outer-alias-names
Open

jrandolf wants to merge 1 commit into
bytecodealliance:mainfrom
jrandolf:wasmprinter-outer-alias-names

Conversation

@jrandolf

@jrandolf jrandolf commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Outer aliases now print the same identifier as the header of the component they refer to, or the alias's count when a scope in between has the same identifier. In three cases, the printed text of a valid component didn't parse or referred to the wrong scope:

  • When a component's name can't be its identifier, such as an empty name, the alias printed the synthetic identifier with its (@name ...) annotation, which only parses where the component is defined. (component (@name "") (type u8) (alias outer 0 0 (type))) printed (alias outer $"#component0 " (@name "") 0 (type)).
  • A nested component's header uses the name its parent gives it, but the alias used the component's own name from its component-name section, so it could refer to an identifier that nothing defines.
  • An inner scope could have the same identifier, which the alias then resolved to instead. A component and its first nested component can both have the synthetic identifier $"#component0 ", for example.

These were found by the grammar-based component fuzzer in #2796.

@jrandolf
jrandolf requested a review from a team as a code owner October 23, 2026 21:54
@jrandolf
jrandolf requested review from alexcrichton and removed request for a team October 23, 2026 21:54
Outer aliases now print the same identifier as the header of the
component they refer to, or its count when a scope in between has the
same identifier. They printed the target's name with its `(@name ...)`
annotation, which only parses where the component is defined; they used
a nested component's own name from its `component-name` section, while
its header uses the name its parent gives it; and they printed
identifiers that an inner scope shadows, such as the synthetic
`$"#component0 "` of both a component and its first nested component,
so the printed text didn't parse or referred to the wrong scope.

    (component (@name "") (type u8) (alias outer 0 0 (type)))

printed `(alias outer $"#component0 " (@name "") 0 (type))`.
@jrandolf
jrandolf force-pushed the wasmprinter-outer-alias-names branch from 6f556a1 to a949791 Compare October 23, 2026 23:52

This branch has not been deployed

No deployments
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