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

Unified Diff: runtime/lib/identical.cc

Issue 317793003: Add javascript compatibility warnings for integer values and integral double (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « no previous file | tests/standalone/javascript_compatibility_errors_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/identical.cc
===================================================================
--- runtime/lib/identical.cc (revision 37016)
+++ runtime/lib/identical.cc (working copy)
@@ -38,8 +38,30 @@
GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1));
const bool is_identical = a.IsIdenticalTo(b);
if (FLAG_warn_on_javascript_compatibility) {
- if (!is_identical && a.IsString() && String::Cast(a).Equals(b)) {
- JSWarning("strings that are equal are also identical");
+ if (!is_identical) {
+ if (a.IsString()) {
+ if (String::Cast(a).Equals(b)) {
+ JSWarning("strings that are equal are also identical");
+ }
+ } else if (a.IsInteger()) {
+ if (b.IsDouble()) {
+ const int64_t a_value = Integer::Cast(a).AsInt64Value();
+ const double b_value = Double::Cast(b).value();
+ if (a_value == floor(b_value)) {
+ JSWarning("integer value and integral double value that are equal "
+ "are also identical");
+ }
+ }
+ } else if (a.IsDouble()) {
+ if (b.IsInteger()) {
+ const double a_value = Double::Cast(a).value();
+ const int64_t b_value = Integer::Cast(b).AsInt64Value();
+ if (floor(a_value) == b_value) {
+ JSWarning("integral double value and integer value that are equal "
+ "are also identical");
+ }
+ }
+ }
}
}
return Bool::Get(is_identical).raw();
« no previous file with comments | « no previous file | tests/standalone/javascript_compatibility_errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698