Skip to content

Commit

Permalink
Fix incorrect parsing of %*.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemaisi committed Sep 26, 2017
1 parent ccfd59d commit bd728e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tokenize.js
Expand Up @@ -221,7 +221,7 @@ pp.readToken_mult_modulo_exp = function(code) { // '%*'
let tokentype = code === 42 ? tt.star : tt.modulo

// exponentiation operator ** and **=
if (this.options.ecmaVersion >= 7 && next === 42) {
if (this.options.ecmaVersion >= 7 && code == 42 && next === 42) {
++size
tokentype = tt.starstar
next = this.input.charCodeAt(this.pos + 2)
Expand Down
4 changes: 4 additions & 0 deletions test/tests-es7.js
Expand Up @@ -342,6 +342,10 @@ test("a-- ** 2", {
"sourceType": "script"
}, {ecmaVersion: 7})

testFail("x %* y", "Unexpected token (1:3)", { ecmaVersion: 7 });

testFail("x %*= y", "Unexpected token (1:3)", { ecmaVersion: 7 });

testFail("function foo(a=2) { 'use strict'; }", "Illegal 'use strict' directive in function with non-simple parameter list (1:0)", { ecmaVersion: 7 })
testFail("(a=2) => { 'use strict'; }", "Illegal 'use strict' directive in function with non-simple parameter list (1:0)", { ecmaVersion: 7 })
testFail("function foo({a}) { 'use strict'; }", "Illegal 'use strict' directive in function with non-simple parameter list (1:0)", { ecmaVersion: 7 })
Expand Down

0 comments on commit bd728e8

Please sign in to comment.