-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing error in exponent expressions with unary left-hand sides (#…
…201) * Fix parsing error in exponent expressions with unary left-hand sides. Esprima (correctly) rejects expressions like -1**2. - jquery/esprima#2070 However, expressions like (-1)**2 are valid but still rejected. This commit fixes this issue by identifying when the left operand is parenthesized. Fixes jquery/esprima#1981 * add test for unary left side
- Loading branch information
1 parent
399986f
commit b7a1ed0
Showing
3 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(+2)**4; |
112 changes: 112 additions & 0 deletions
112
test/Esprima.Tests/Fixtures/invalid-syntax/unary_left_side.tree.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ | ||
"type": "Program", | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"expression": { | ||
"type": "BinaryExpression", | ||
"operator": "**", | ||
"left": { | ||
"type": "UnaryExpression", | ||
"operator": "+", | ||
"argument": { | ||
"type": "Literal", | ||
"value": 2, | ||
"raw": "2", | ||
"range": [ | ||
2, | ||
3 | ||
], | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 3 | ||
} | ||
} | ||
}, | ||
"prefix": true, | ||
"range": [ | ||
1, | ||
3 | ||
], | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 3 | ||
} | ||
} | ||
}, | ||
"right": { | ||
"type": "Literal", | ||
"value": 4, | ||
"raw": "4", | ||
"range": [ | ||
6, | ||
7 | ||
], | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 6 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 7 | ||
} | ||
} | ||
}, | ||
"range": [ | ||
0, | ||
7 | ||
], | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 7 | ||
} | ||
} | ||
}, | ||
"range": [ | ||
0, | ||
8 | ||
], | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 8 | ||
} | ||
} | ||
} | ||
], | ||
"sourceType": "script", | ||
"range": [ | ||
0, | ||
8 | ||
], | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 8 | ||
} | ||
} | ||
} |