diff --git a/crates/runtime/src/instance.rs b/crates/runtime/src/instance.rs index cf81701fd7ef..0faa14d7c044 100644 --- a/crates/runtime/src/instance.rs +++ b/crates/runtime/src/instance.rs @@ -801,7 +801,12 @@ impl Instance { // disconnected from the lifetime of `self`. let module = self.module().clone(); - let empty = TableSegmentElements::Functions(Box::new([])); + // NB: fall back to an expressions-based list of elements which doesn't + // have static type information (as opposed to `Functions`) since we + // don't know just yet what type the table has. The type will be be + // inferred in the next step within `table_init_segment`. + let empty = TableSegmentElements::Expressions(Box::new([])); + let elements = match module.passive_elements_map.get(&elem_index) { Some(index) if !self.dropped_elements.contains(elem_index) => { &module.passive_elements[*index] diff --git a/tests/misc_testsuite/externref-table-dropped-segment-issue-8281.wast b/tests/misc_testsuite/externref-table-dropped-segment-issue-8281.wast new file mode 100644 index 000000000000..d081bc7531b2 --- /dev/null +++ b/tests/misc_testsuite/externref-table-dropped-segment-issue-8281.wast @@ -0,0 +1,11 @@ +(module + (table $2 0 0 externref) + (func (export "table") + (i32.const 0) + (i32.const 0) + (i32.const 0) + (table.init 0 0) + ) + (elem $2 declare externref) +) +(assert_return (invoke "table"))