Skip to content
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
20 changes: 12 additions & 8 deletions crates/environ/src/component/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use indexmap::IndexMap;
use std::collections::{HashMap, HashSet};
use std::mem;
use wasmparser::component_types::{
AliasableResourceId, ComponentCoreModuleTypeId, ComponentDefinedTypeId, ComponentEntityType,
ComponentFuncTypeId, ComponentInstanceTypeId, ComponentValType,
AliasableResourceId, ComponentCoreModuleTypeId, ComponentCoreTypeId, ComponentDefinedTypeId,
ComponentEntityType, ComponentFuncTypeId, ComponentInstanceTypeId, ComponentValType,
};
use wasmparser::types::Types;
use wasmparser::{Chunk, ComponentExternName, Encoding, Parser, Payload, Validator};
Expand Down Expand Up @@ -903,17 +903,21 @@ impl<'a, 'data> Translator<'a, 'data> {
.core_type_count_in_component();
self.validator.core_type_section(&s)?;
let types = self.validator.types(0).unwrap();
for ty in s {
match ty? {
wasmparser::CoreType::Rec(group) => {
let id = types.core_type_at_in_component(index).unwrap_sub();
let count = types.core_type_count_in_component();
while index < count {
match types.core_type_at_in_component(index) {
// The current type index is always the first type of
// its rec group, so intern the group and then skip
// past the rest of its types.
ComponentCoreTypeId::Sub(id) => {
let group_id = types.rec_group_id_of(id);
self.types
.module_types_builder()
.intern_rec_group(types, group_id)?;
index += u32::try_from(group.types().len()).unwrap();
index +=
u32::try_from(types.rec_group_elements(group_id).len()).unwrap();
}
wasmparser::CoreType::Module(_) => index += 1,
ComponentCoreTypeId::Module(_) => index += 1,
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/misc_testsuite/component-model/empty-rec-groups.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
;;! gc = true

;; Empty core rec groups define no types.
(component (core rec))
(component (core rec) (core type (module)))
(component (core type (sub (array i8))) (core rec))
Loading