Skip to content

Commit 334471b

Browse files
rajatdpleath
authored andcommitted
1 parent 8943e33 commit 334471b

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

lib/Runtime/Language/ValueType.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,10 @@ ValueType ValueType::MergeWithObject(const ValueType other) const
10551055
{
10561056
// Any two different specific object types (excludes UninitializedObject and Object, which don't indicate any
10571057
// specific type of object) merge to Object since the resulting type is not guaranteed to indicate any specific type
1058+
if (IsArrayOrObjectWithArray() || other.IsArrayOrObjectWithArray())
1059+
{
1060+
return Verify(GetObject(ObjectType::Object).ToLikely());
1061+
}
10581062
merged.SetObjectType(ObjectType::Object);
10591063
return Verify(merged);
10601064
}
@@ -1945,13 +1949,18 @@ void ValueType::RunUnitTests()
19451949
));
19461950

19471951
if(!(
1948-
t0.IsObject() && t1.IsObject() && // both are objects
1952+
t0.IsObject() && t1.IsObject() && // both are objects
19491953
(
1950-
t0.GetObjectType() == ObjectType::UninitializedObject ||
1951-
t1.GetObjectType() == ObjectType::UninitializedObject
1952-
) && // one has an uninitialized object type
1953-
(t0.GetObjectType() > ObjectType::Object || t1.GetObjectType() > ObjectType::Object) // one has a specific object type
1954-
)) // then the resulting object type is not guaranteed
1954+
(
1955+
(
1956+
t0.GetObjectType() == ObjectType::UninitializedObject ||
1957+
t1.GetObjectType() == ObjectType::UninitializedObject
1958+
) && // one has an uninitialized object type
1959+
(t0.GetObjectType() > ObjectType::Object || t1.GetObjectType() > ObjectType::Object) // one has a specific object type
1960+
) ||
1961+
(t0.IsArrayOrObjectWithArray() || t1.IsArrayOrObjectWithArray()) // or one was an array or an object with array
1962+
)
1963+
)) // then the resulting object type is not guaranteed
19551964
{
19561965
Assert(m.IsNotInt() == (t0.IsNotInt() && t1.IsNotInt()));
19571966
}
@@ -1990,13 +1999,18 @@ void ValueType::RunUnitTests()
19901999
Assert(m.IsLikelyString() == (t0.IsLikelyString() && t1.IsLikelyString()));
19912000

19922001
if(!(
1993-
t0.IsObject() && t1.IsObject() && // both are objects
2002+
t0.IsObject() && t1.IsObject() && // both are objects
19942003
(
1995-
t0.GetObjectType() == ObjectType::UninitializedObject ||
1996-
t1.GetObjectType() == ObjectType::UninitializedObject
1997-
) && // one has an uninitialized object type
1998-
(t0.GetObjectType() > ObjectType::Object || t1.GetObjectType() > ObjectType::Object) // one has a specific object type
1999-
)) // then the resulting object type is not guaranteed
2004+
(
2005+
(
2006+
t0.GetObjectType() == ObjectType::UninitializedObject ||
2007+
t1.GetObjectType() == ObjectType::UninitializedObject
2008+
) && // one has an uninitialized object type
2009+
(t0.GetObjectType() > ObjectType::Object || t1.GetObjectType() > ObjectType::Object) // one has a specific object type
2010+
) ||
2011+
(t0.IsArrayOrObjectWithArray() || t1.IsArrayOrObjectWithArray()) // or one was an array or an object with array
2012+
)
2013+
)) // then the resulting object type is not guaranteed
20002014
{
20012015
Assert(m.IsObject() == (t0.IsObject() && t1.IsObject()));
20022016
}

0 commit comments

Comments
 (0)