Skip to content

Commit fb7b2c5

Browse files
Use table's index type when parsing element segments (#8380)
Resolves the spec test error in call_indirect64.wast: ``` run_command `/usr/local/google/home/stevenfont/code/binaryen3/bin/wasm-shell /usr/local/google/home/stevenfont/code/binaryen3/test/spec/testsuite/call_indirect64.wast` failed (1) 0 BUILDING MODULE [line: 3] [wasm-validator error in module] i32 != i64: element segment offset must match table index type, on (i32.const 0) failed validation ``` Previously we always assumed a 32-bit index even if the table is 64 bits. Use the index type of the table during parsing. Part of #8261.
1 parent 72cd1b3 commit fb7b2c5

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

scripts/test/shared.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ def get_tests(test_dir, extensions=[], recursive=False):
404404
SPEC_TESTSUITE_TESTS_TO_SKIP = [
405405
'array_new_elem.wast', # Failure to parse element segment item abbreviation
406406
'binary.wast', # Missing data count section validation
407-
'call_indirect64.wast', # Failure to parse element segment abbreviation
408407
'comments.wast', # Issue with carriage returns being treated as newlines
409408
'const.wast', # Hex float constant not recognized as out of range
410409
'conversions.wast', # Promoted NaN should be canonical

src/parser/context-decls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Result<> ParseDeclsCtx::addImplicitElems(TypeT, ElemListT&& elems) {
122122
auto& table = *wasm.tables.back();
123123
auto e = std::make_unique<ElementSegment>();
124124
e->table = table.name;
125-
e->offset = Builder(wasm).makeConstPtr(0, Type::i32);
125+
e->offset = Builder(wasm).makeConstPtr(0, table.addressType);
126126
e->name = Names::getValidElementSegmentName(wasm, "implicit-elem");
127127
wasm.addElementSegment(std::move(e));
128128

0 commit comments

Comments
 (0)