diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-02-04 08:31:10 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-02-04 12:46:48 +0100 |
commit | a8bc011d459a4d080815a2675f2a0413c8bf09d2 (patch) | |
tree | b1ce28a37ccff86543ff6595bb5ab6be47f8ca7f /src/qml/jsruntime/qv4value.cpp | |
parent | ac46c9f6ce9ef757e0ccba8a283cb0efabaef56e (diff) |
QV4: Handle value tyes in sameValue algorithm
The sameValue(Zero) algorithm were implemented according to the
JavaScript specification; however QML has the concept of value types.
For those we need to check equality with the intrinsic isEqualTo method.
This aligns sameValue(Zero) with strict equality in its treatment of
value types.
This fixes Array.includes for value types
Fixes: QTBUG-81825
Change-Id: Idd3e09cbed94bca6ea44f5683610b87d184e432c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4value.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4value.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index d29b060b9e..3449603a8a 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -250,6 +250,8 @@ bool Value::sameValue(Value other) const { if (isDouble() && other.isInteger()) return other.int_32() ? (doubleValue() == double(other.int_32())) : (doubleValue() == 0 && !std::signbit(doubleValue())); + if (isManaged()) + return other.isManaged() && cast<Managed>()->isEqualTo(other.cast<Managed>()); return false; } @@ -269,6 +271,8 @@ bool Value::sameValueZero(Value other) const { return true; } } + if (isManaged()) + return other.isManaged() && cast<Managed>()->isEqualTo(other.cast<Managed>()); return false; } |