Closed r1ru closed 7 months ago
Hm, I'm confused, can you elaborate what is inconsistent? (Note that the text format has no explicit representation of the data count section, it is implied when there is a non-zero number of data segments.)
Okay, then this is my mistake. I thoght it is inconsistent because when I input the above memory_init.wast into wast2json, it outputs wasm binaries without the data count section. Probably this is a bug of wast2json. Sorry.
Well, strictly speaking, the spec requires a data count section iff there is at least one occurrence of a data index in the program, which is the case in the first example. But that also has no data segment, hence it would be invalid either way. In practical terms, it doesn't really matter what a tool does in the case of invalid input, so I'm not sure I would necessarily count it as a bug.
The following two test cases exist in memory_init.wast
https://github.com/WebAssembly/spec/blob/main/test/core/memory_init.wast#L189-L193 https://github.com/WebAssembly/spec/blob/main/test/core/memory_init.wast#L226-L230
However, what is expected in these tests is not consistent with what is expected in binary.wast below.
https://github.com/WebAssembly/spec/blob/main/test/core/binary.wast#L472-L511
These two tests should also fail at the decoding stage because the data count section is not defined. Therefore, these tests should be modified or deleted.