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

Unified Diff: pkg/js_ast/lib/src/printer.dart

Issue 1438633002: js_ast: Avoid precedence issue with negative numbers as receivers at calls (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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/js_ast/lib/src/nodes.dart ('k') | tests/compiler/dart2js/js_constant_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/js_ast/lib/src/printer.dart
diff --git a/pkg/js_ast/lib/src/printer.dart b/pkg/js_ast/lib/src/printer.dart
index 7a1124f744580a4887f4c612bab17b7518b7e736..b2fd29d3058d42536ae480494f789bfd0c841736 100644
--- a/pkg/js_ast/lib/src/printer.dart
+++ b/pkg/js_ast/lib/src/printer.dart
@@ -933,7 +933,10 @@ class Printer implements NodeVisitor {
LiteralString selectorString = selector;
String fieldWithQuotes = selectorString.value;
if (isValidJavaScriptId(fieldWithQuotes)) {
- if (access.receiver is LiteralNumber) out(" ", isWhitespace: true);
+ if (access.receiver is LiteralNumber &&
+ lastCharCode != charCodes.$CLOSE_PAREN) {
+ out(" ", isWhitespace: true);
+ }
out(".");
startNode(selector);
out(fieldWithQuotes.substring(1, fieldWithQuotes.length - 1));
@@ -941,7 +944,10 @@ class Printer implements NodeVisitor {
return;
}
} else if (selector is Name) {
- if (access.receiver is LiteralNumber) out(" ", isWhitespace: true);
+ if (access.receiver is LiteralNumber &&
+ lastCharCode != charCodes.$CLOSE_PAREN) {
+ out(" ", isWhitespace: true);
+ }
out(".");
startNode(selector);
selector.accept(this);
@@ -1487,4 +1493,4 @@ class EnterExitNode {
context.exitNode(node, startPosition, position, closingPosition);
return parent;
}
-}
+}
« no previous file with comments | « pkg/js_ast/lib/src/nodes.dart ('k') | tests/compiler/dart2js/js_constant_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698