Skip to content

Commit 7cd76de

Browse files
Make table subtyping invariant (#8489)
Table subtyping for imports should be invariant according to the spec: <img width="574" height="192" alt="image" src="https://github.com/user-attachments/assets/dacd3d80-870a-4680-bd33-7535e70fa73f" />. This makes sense because the exporter might write the supertype and the importer may later try to read a subtype which would be wrong. The other copy of `linking.wast` is no longer relevant and doesn't pass with these changes. Our copy: [link](https://github.com/WebAssembly/binaryen/blob/899e44e2c3dd40795c843a91cfc326e11d64cab0/test/spec/linking.wast#L236), upstream test: [link](https://github.com/WebAssembly/testsuite/blob/main/linking.wast#L399-L400) (see line 410 which differs from our copy of the test). Part of #8261.
1 parent 86f0e8a commit 7cd76de

File tree

3 files changed

+2
-394
lines changed

3 files changed

+2
-394
lines changed

scripts/test/shared.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,6 @@ def get_tests(test_dir, extensions=[], recursive=False):
387387
# Requires us to write our own floating point parser
388388
'const.wast',
389389

390-
# Unlinkable module accepted
391-
'linking.wast',
392-
393390
# Invalid module accepted
394391
'unreached-invalid.wast',
395392

@@ -423,7 +420,6 @@ def get_tests(test_dir, extensions=[], recursive=False):
423420
'if.wast', # Requires more precise unreachable validation
424421
'imports.wast', # Requires fixing handling of mutation to imported globals
425422
'proposals/threads/imports.wast', # Missing memory type validation on instantiation
426-
'linking.wast', # Incorrectly allows covariant subtyping for table imports
427423
'proposals/threads/memory.wast', # Missing memory type validation on instantiation
428424
'annotations.wast', # String annotations IDs should be allowed
429425
'instance.wast', # Requires support for table default elements

src/ir/runtime-table.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class RuntimeTable {
4747
// be imported with the definition of `other`
4848
virtual bool isSubType(const Table& other) {
4949
return tableDefinition.addressType == other.addressType &&
50-
Type::isSubType(tableDefinition.type, other.type) &&
51-
size() >= other.initial && tableDefinition.max <= other.max;
50+
tableDefinition.type == other.type && size() >= other.initial &&
51+
tableDefinition.max <= other.max;
5252
}
5353

5454
const Table* getDefinition() const { return &tableDefinition; }

0 commit comments

Comments
 (0)