Repository navigation
Read @name annotations on functions and tags - #496
Merged
Merged
Conversation
The encoder wrote no tag name subsection (id 11), so a tag's `$id` was lost, and the encoder tests had to drop that subsection from wasm-tools' output before comparing. Write it like the other name maps, and compare the whole name section with wasm-tools again. The name maps now hold names without the `$`, so that a name can also come from somewhere other than a `$id`.
The parser took `(@name "...")` only on a module, so a function or tag carrying one failed to parse, and custom/name_annot.wast skipped the two modules that use them. Take it after the `$id` of a function or tag, defined or imported, as the spec's name annotation appendix places it. The name section prefers it over the `$id`, as it already does for the module name. Parameters, locals, types and fields can carry one too, but no spec test uses them yet.
kateinoigakukun
force-pushed
the
name-annot
branch
from
October 4, 2026 14:06
cb7c8bc to
6fda7df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
custom/name_annot.wastnow runs with no skipped directives. The WAT parser accepts(@name "...")on functions and tags, both defined and imported, and the name section uses it instead of the$id. Tag names (name subsection 11) are now written too, so the encoder tests compare the whole name section with wasm-tools again.What's included
Tag names in the name section
The encoder didn't write the tag name subsection, so a tag's
$idwas lost. The encoder tests were dropping subsection 11 from wasm-tools' output to hide this. The encoder now writes it like the other name maps, and the comparison no longer filters it out. This is its own commit.The name maps now hold names without the
$, so a name can also come from an annotation. A smallnameMapEntrieshelper replaces the seven copies of the samecompactMap.@nameon functions and tagsThe parser took
@nameonly on a module, so a function or tag with one failed to parse. It's now taken directly after the optional$idof afuncortagfield, and of a function or tag import, as the spec's name annotation appendix places it. As with module names, an annotation takes precedence over the$idin the name section.A misplaced or second annotation is still rejected as an unexpected token.
Testing
swift test --traits FileSystem,MultiThread,Disassembler,ComponentModel --filter "WATTests|Spectest"passes.name_annot.wastpasses under both threading models.Tests/WasmKitTests/ExtraSuite/annotations/name.wastnow covers functions and tags: defined, imported and exported, with and without a$id, and three malformed placements. The encoder tests check its name section byte-for-byte against wasm-tools.@nameon a tag import, though the spec allows it. That module is written as(module quote ...), so the engine parses and links it but the encoder tests don't compare it.Not included
@nameon parameters, locals, types and struct fields, which the spec also allows. No spec test uses them yet.NameSectionParser. It still skips subsection 11.