Fix the sameValue algorithm when comparing ints to doubles.
authorLars Knoll <lars.knoll@digia.com>
Sat, 16 Feb 2013 22:26:16 +0000 (23:26 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 25 Feb 2013 07:03:24 +0000 (08:03 +0100)
Change-Id: I96fb3e8c47a336ef4e0e3cab44e6dfd4d5aff70a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/v4/qmljs_value.cpp

index 91f4ec8..892bcdf 100644 (file)
@@ -92,10 +92,10 @@ bool Value::sameValue(Value other) const {
         return true;
     if (isString() && other.isString())
         return stringValue()->isEqualTo(other.stringValue());
-    if (isInteger() && int_32 == 0 && other.dbl == 0)
-        return true;
-    if (dbl == 0 && other.isInteger() && other.int_32 == 0)
-        return true;
+    if (isInteger())
+        return int_32 ? (double(int_32) == other.dbl) : (other.val == 0);
+    if (other.isInteger())
+        return other.int_32 ? (dbl == double(other.int_32)) : (val == 0);
     return false;
 }