-
Notifications
You must be signed in to change notification settings - Fork 61
Description
The test here:
Lines 189 to 193 in aa6e47b
| (assert_invalid | |
| (module | |
| (func (export "test") | |
| (data.drop 0))) | |
| "unknown data segment") |
Specifies that this is an invalid module. Indeed, attempting to compile the module with wat2wasm leads to:
❯ wat2wasm src/test/resources/assembler/simple.wat -o /tmp/simple.wasm
src/test/resources/assembler/simple.wat:3:16: error: data_segment variable out of range: 0 (max 0)
(data.drop 0)))
Notably, the error message is different. Further, wast2json compiles with effectively --no-check, which however doesn't actually yield an invalid module, but a malformed one:
❯ wat2wasm src/test/resources/assembler/simple.wat -o /tmp/simple.wasm --no-check
❯ wasm2wat /tmp/simple.wasm -o /tmp/simple.wat
0000023: error: data.drop requires data count section
This seems to more or less be the following check:
Lines 515 to 533 in aa6e47b
| ;; data.drop requires a data count section | |
| (assert_malformed | |
| (module binary | |
| "\00asm" "\01\00\00\00" | |
| "\01\04\01\60\00\00" ;; Type section | |
| "\03\02\01\00" ;; Function section | |
| "\05\03\01\00\00" ;; Memory section | |
| "\0a\07\01" ;; Code section | |
| ;; function 0 | |
| "\05\00" | |
| "\fc\09\00" ;; data.drop | |
| "\0b" | |
| "\0b\03\01\01\00" ;; Data section | |
| ) ;; end | |
| "data count section required" | |
| ) |
So the question now is whether this is a malformed module (though then it shouldn't even be possibly to create it with --no-check as far as I understand) or an invalid module, but then the binary tests would be wrong.
(NOTE: the same applies to the memory.init tests)
To be clear why I'm raising this issue: While testing my WASM implementation against the spec tests I noticed that I fail the assert_invalid tests from above because my implementation asserts them as malformed, and moving this check to the validation phase makes it fail the assert_malformed tests.