Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: src/runtime.js

Issue 1130283002: [strong] Disallow implicit conversions for comparison (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: minor cleanup Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index 004f9bf61bcdd1a088f12696b7216c0ead17f1c6..a1b577d7e6c91fe5eaf64ae49e4bdf74240d9f92 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -203,6 +203,14 @@ COMPARE = function COMPARE(x, ncr) {
}
}
+//Strong mode COMPARE throws if an implicit conversion would be performed
rossberg 2015/05/08 13:54:36 Nit: space
conradw 2015/05/08 14:08:21 Done.
+COMPARE_STRONG = function COMPARE_STRONG(x, ncr) {
+ if (IS_STRING(this) && IS_STRING(x)) return %_StringCompare(this, x);
+ if (IS_NUMBER(this) && IS_NUMBER(x)) return %NumberCompare(this, x, ncr);
+
+ throw %MakeTypeError('strong_implicit_cast');
+}
+
/* -----------------------------------
« src/ic/ic.h ('K') | « src/ppc/lithium-ppc.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698