Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasmparser: Fix subtyping depth indexing #1968

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/wasmparser/src/validator/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ impl TypeList {
let depth = self
.core_type_to_depth
.as_ref()
.expect("cannot get subtype depth from a committed list")[id.index()];
.expect("cannot get subtype depth from a committed list")[&id];
debug_assert!(usize::from(depth) <= crate::limits::MAX_WASM_SUBTYPING_DEPTH);
depth
}
Expand Down
9 changes: 9 additions & 0 deletions tests/local/component-model/gc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,12 @@
))
)
"sub type cannot have a final super type")

(component
(type $t (resource (rep i32)))
(core func (canon resource.drop $t))
(core module
(type $t1 (sub (func)))
(type (sub $t1 (func)))
)
)
6 changes: 6 additions & 0 deletions tests/snapshots/local/component-model/gc.wast.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
"filename": "gc.11.wasm",
"module_type": "binary",
"text": "sub type cannot have a final super type"
},
{
"type": "module",
"line": 128,
"filename": "gc.12.wasm",
"module_type": "binary"
}
]
}
8 changes: 8 additions & 0 deletions tests/snapshots/local/component-model/gc.wast/12.print
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(component
(type $t (;0;) (resource (rep i32)))
(core func (;0;) (canon resource.drop $t))
(core module (;0;)
(type $t1 (;0;) (sub (func)))
(type (;1;) (sub $t1 (func)))
)
)
Loading