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

Unified Diff: dart/frog/leg/lib/js_helper.dart

Issue 9536012: Special case -0.0 when constant folding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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 | dart/frog/leg/ssa/nodes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/lib/js_helper.dart
diff --git a/dart/frog/leg/lib/js_helper.dart b/dart/frog/leg/lib/js_helper.dart
index 6c534e90f663c6203e24d558ce69cb792792849d..1817c5ad354d622daacaa43be50a6bf39e0bec11 100644
--- a/dart/frog/leg/lib/js_helper.dart
+++ b/dart/frog/leg/lib/js_helper.dart
@@ -1141,7 +1141,13 @@ class MathNatives {
checkNull(str);
if (str is !String) throw new IllegalArgumentException();
var ret = JS('num', @'parseFloat($0)', str);
- if (ret.isNaN() && str != 'NaN') throw new BadNumberFormatException(str);
+ if (ret == 0 && (str.startsWith("0x") || str.startsWith("0X"))) {
+ // TODO(ahe): This is unspecified, but tested by co19.
floitsch 2012/02/29 15:33:46 please file a bug that this should not be allowed.
ahe 2012/02/29 18:42:55 I have filed a co19 bug.
+ ret = JS('num', @'parseInt($0)', str);
+ }
+ if (ret.isNaN() && str != 'NaN' && str != '-NaN') {
+ throw new BadNumberFormatException(str);
+ }
return ret;
}
« no previous file with comments | « no previous file | dart/frog/leg/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698