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

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 9284029: Issue 1229. Report error for using unary plus operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « no previous file | compiler/java/com/google/dart/compiler/parser/ParserErrorCode.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java
index dffb6799ac861dbd73aee0e5806071fd3085aa55..3dc9d755c09d53a8a3b5bc8ce39381691e4e7491 100644
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
@@ -3637,8 +3637,14 @@ public class DartParser extends CompletionHooksParserBase {
* </pre>
*/
private DartExpression parseUnaryExpression() {
- // A '+' prefix does not have any effect.
- optional(Token.ADD);
+ // There is no unary plus operator in Dart.
+ // However, we allow a leading plus in decimal numeric literals.
+ if (optional(Token.ADD)) {
+ if (peek(0) != Token.INTEGER_LITERAL && peek(0) != Token.DOUBLE_LITERAL) {
+ reportError(position(), ParserErrorCode.NO_UNARY_PLUS_OPERATOR);
+ }
+ }
+ // Check for unary minus operator.
Token token = peek(0);
if (token.isUnaryOperator() || token == Token.SUB) {
beginUnaryExpression();
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/parser/ParserErrorCode.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698