@@ -1055,6 +1055,10 @@ ValueType ValueType::MergeWithObject(const ValueType other) const
1055
1055
{
1056
1056
// Any two different specific object types (excludes UninitializedObject and Object, which don't indicate any
1057
1057
// 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
+ }
1058
1062
merged.SetObjectType (ObjectType::Object);
1059
1063
return Verify (merged);
1060
1064
}
@@ -1945,13 +1949,18 @@ void ValueType::RunUnitTests()
1945
1949
));
1946
1950
1947
1951
if (!(
1948
- t0.IsObject () && t1.IsObject () && // both are objects
1952
+ t0.IsObject () && t1.IsObject () && // both are objects
1949
1953
(
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
1955
1964
{
1956
1965
Assert (m.IsNotInt () == (t0.IsNotInt () && t1.IsNotInt ()));
1957
1966
}
@@ -1990,13 +1999,18 @@ void ValueType::RunUnitTests()
1990
1999
Assert (m.IsLikelyString () == (t0.IsLikelyString () && t1.IsLikelyString ()));
1991
2000
1992
2001
if (!(
1993
- t0.IsObject () && t1.IsObject () && // both are objects
2002
+ t0.IsObject () && t1.IsObject () && // both are objects
1994
2003
(
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
2000
2014
{
2001
2015
Assert (m.IsObject () == (t0.IsObject () && t1.IsObject ()));
2002
2016
}
0 commit comments