Skip to content

Commit 7a1061b

Browse files
alexcrichtonbongjunj
authored andcommitted
Adjust depth calculation of map<K, V> type (bytecodealliance#12760)
Previously it added 2 but this meant that it was out-of-sync with the fuzz test case generator which only accounted for 1 for each level of map. There's no need to have an extra layer for maps, so adjust the depth to add 1 instead of 2 which fixes the fuzz test case in question.
1 parent 01ad805 commit 7a1061b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

crates/environ/src/component/types_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,8 @@ impl TypeInformation {
12281228
*self = TypeInformation::string();
12291229
let key_info = types.type_information(&ty.key);
12301230
let value_info = types.type_information(&ty.value);
1231-
// Depth is max of key/value depths, plus 1 for tuple, plus 1 for list
1232-
self.depth = key_info.depth.max(value_info.depth) + 2;
1231+
// Depth is max of key/value depths, plus 1 for the extra map layer.
1232+
self.depth = key_info.depth.max(value_info.depth) + 1;
12331233
self.has_borrow = key_info.has_borrow || value_info.has_borrow;
12341234
}
12351235
}

0 commit comments

Comments
 (0)