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

Unified Diff: pkg/compiler/lib/src/js_backend/constant_system_javascript.dart

Issue 1635053002: dart2js: Match the runtime int is check semantics at compile time. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Incorporate review comments. Created 4 years, 11 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
« no previous file with comments | « pkg/compiler/lib/src/constants/values.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
diff --git a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
index 290d563259dd393b4b5d0bda51b1008d7ca2f710..f6ebd0770f0861803484dc25f0068d81cbf37a09 100644
--- a/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_system_javascript.dart
@@ -274,8 +274,17 @@ class JavaScriptConstantSystem extends ConstantSystem {
compiler.backend.typeImplementation.computeType(compiler.resolution));
}
- // Integer checks don't verify that the number is not -0.0.
- bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero;
+ // Integer checks report true for -0.0, INFINITY, and -INFINITY. At
+ // runtime an 'X is int' check is implemented as:
+ //
+ // typeof(X) === "number" && Math.floor(X) === X
+ //
+ // We consistently match that runtime semantics at compile time as well.
+ bool isInt(ConstantValue constant) {
+ return constant.isInt || constant.isMinusZero ||
+ constant.isPositiveInfinity ||
+ constant.isNegativeInfinity;
+ }
bool isDouble(ConstantValue constant)
=> constant.isDouble && !constant.isMinusZero;
bool isString(ConstantValue constant) => constant.isString;
« no previous file with comments | « pkg/compiler/lib/src/constants/values.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698