Skip to content

Ensure that inline (data)s and (elem)s count toward identifiers - #2242

Merged
rossberg merged 4 commits into
WebAssembly:mainfrom
bvisness:data-elem-ids
Sep 3, 2026
Merged

Ensure that inline (data)s and (elem)s count toward identifiers#2242
rossberg merged 4 commits into
WebAssembly:mainfrom
bvisness:data-elem-ids

Conversation

@bvisness

@bvisness bvisness commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The (memory (data ...)) and (table (elem ...)) abbreviations were not correctly counting the indices of the data and elem segments, causing the identifiers' indices on later data and elem segments to be off by one. Because the identifier context needs to be updated as we parse, memory_fields and table_fields are updated to do some of their work in the first pass.

The (memory (data ...)) and (table (elem ...)) syntax sugar was not
correctly counting the indices of the data and elem segments, causing
the identifiers' indices on later data and elem segments to be off by one.
Because the identifier context needs to be updated as we parse,
memory_fields and table_fields are updated to do some of their work in
the first pass.

@rossberg rossberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks! That must have been a pain to debug, since this code is a mess.

Comment thread interpreter/text/parser.mly
Comment thread interpreter/text/parser.mly Outdated
@redianthus

Copy link
Copy Markdown
Contributor

I feel like having a test for this would be a nice addition, would you be willing to add one @bvisness?

@bvisness

bvisness commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I went back and forth on including tests because they are very fiddly, identifier-specific, and...where would they go? Do we have a place for "regression tests" of sorts? I'm happy to add one, it's just so niche that I struggled with it.

@rossberg

rossberg commented Sep 3, 2026

Copy link
Copy Markdown
Member

I think elem.wast and data.wast would be natural places. They aren't really regression tests (nor do I see a need to distinguish those in the test suite).

@bvisness

bvisness commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I added some tests that fail on main with an out-of-bounds access due to the identifier referring to the dropped data/elem segment.

@rossberg
rossberg merged commit 37d6b05 into WebAssembly:main Sep 3, 2026
1 check passed
@bvisness
bvisness deleted the data-elem-ids branch September 3, 2026 20:35
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.

3 participants