Commit f914ff7
authored
[Types] Fix missing inverse check for described field in isValidSupertype (#8378)
## Summary
- Add the missing `else` branch in `isValidSupertype` for the
`described` field check, making it symmetric with the existing
`descriptor` field check.
- Without this fix, a type without a `describes` clause can illegally
subtype a type that has a `describes` clause (i.e., a descriptor type),
as long as all features are enabled.
- The `descriptor` check already handles both directions (if sub has no
descriptor, super must also have no descriptor), but the `described`
check was missing the inverse direction.
## Details
In `isValidSupertype` (src/wasm/wasm-type.cpp), the validation for
`descriptor` is fully symmetric:
```cpp
if (sub.descriptor) {
if (super.descriptor && sub.descriptor->supertype != super.descriptor) {
return false;
}
} else {
if (super.descriptor) { return false; }
}
```
But the `described` check was missing the else branch:
```cpp
if (sub.described) {
if (!super.described || sub.described->supertype != super.described) {
return false;
}
}
// Missing: else { if (super.described) { return false; } }
```
The spec test at `test/spec/descriptors.wast` (lines 152-161) already
covers this case with an `assert_invalid` for "supertype of
non-descriptor type cannot be a descriptor". However, the test currently
passes for the wrong reason: `wasm-shell` re-parses `assert_invalid`
modules as quoted text modules without features enabled, so
`TypeBuilder::build()` rejects the module with
`RequiresCustomDescriptors` before ever reaching `isValidSupertype`.
When the module is loaded through the normal inline parse path (with all
features enabled), the invalid subtyping relationship is incorrectly
accepted.
## Test plan
- Verified that `wasm-shell test/spec/descriptors.wast` passes all 14
checks (including the one at line 152)
- Verified that all 309 GTest unit tests pass1 parent 67e7170 commit f914ff7
2 files changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2418 | 2418 | | |
2419 | 2419 | | |
2420 | 2420 | | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
2421 | 2427 | | |
2422 | 2428 | | |
2423 | 2429 | | |
| |||
0 commit comments