Index: src/runtime.js |
=================================================================== |
--- src/runtime.js (revision 4966) |
+++ src/runtime.js (working copy) |
@@ -112,7 +112,7 @@ |
// the result when either (or both) the operands are NaN. |
function COMPARE(x, ncr) { |
var left; |
- |
+ var right; |
// Fast cases for string, numbers and undefined compares. |
if (IS_STRING(this)) { |
if (IS_STRING(x)) return %_StringCompare(this, x); |
@@ -123,14 +123,18 @@ |
if (IS_UNDEFINED(x)) return ncr; |
left = this; |
} else if (IS_UNDEFINED(this)) { |
+ if (!IS_UNDEFINED(x)) { |
+ %ToPrimitive(x, NUMBER_HINT); |
+ } |
return ncr; |
+ } else if (IS_UNDEFINED(x)) { |
+ %ToPrimitive(this, NUMBER_HINT); |
+ return ncr; |
} else { |
- if (IS_UNDEFINED(x)) return ncr; |
left = %ToPrimitive(this, NUMBER_HINT); |
} |
- // Default implementation. |
- var right = %ToPrimitive(x, NUMBER_HINT); |
+ right = %ToPrimitive(x, NUMBER_HINT); |
if (IS_STRING(left) && IS_STRING(right)) { |
return %_StringCompare(left, right); |
} else { |