Skip to content

Commit de13919

Browse files
authored
Handle sharedness in RefEq in subtype-exprs.h (#7977)
If we don't report the right sharedness, the fuzzer can replace shared code with unshared, and error.
1 parent a7c3915 commit de13919

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/ir/subtype-exprs.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,15 @@ struct SubtypingDiscoverer : public OverriddenVisitor<SubType> {
223223
void visitRefIsNull(RefIsNull* curr) {}
224224
void visitRefFunc(RefFunc* curr) {}
225225
void visitRefEq(RefEq* curr) {
226-
self()->noteNonFlowSubtype(curr->left, Type(HeapType::eq, Nullable));
227-
self()->noteNonFlowSubtype(curr->right, Type(HeapType::eq, Nullable));
226+
// Match the shareability of the current content (if it exists).
227+
// TODO: This could also allow both sides to flip.
228+
HeapType eq = HeapType::eq;
229+
if (curr->type != Type::unreachable) {
230+
eq = eq.getBasic(curr->left->type.getHeapType().getShared());
231+
}
232+
auto type = Type(eq, Nullable);
233+
self()->noteNonFlowSubtype(curr->left, type);
234+
self()->noteNonFlowSubtype(curr->right, type);
228235
}
229236
void visitTableGet(TableGet* curr) {}
230237
void visitTableSet(TableSet* curr) {

0 commit comments

Comments
 (0)