From 0c12f63f171d8a6c8b354de54a7ff4a8d5fa486e Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 7 Sep 2018 22:19:36 +0200 Subject: [PATCH] Fix tokenizing of regexps after .of Closes #727 --- src/tokencontext.js | 2 +- test/tests-harmony.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tokencontext.js b/src/tokencontext.js index 5151b3320..6395dd829 100644 --- a/src/tokencontext.js +++ b/src/tokencontext.js @@ -139,7 +139,7 @@ tt.star.updateContext = function(prevType) { tt.name.updateContext = function(prevType) { let allowed = false - if (this.options.ecmaVersion >= 6) { + if (this.options.ecmaVersion >= 6 && prevType != tt.dot) { if (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) allowed = true diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 0040e0a51..9b6da12be 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -16241,3 +16241,5 @@ test('for ([...foo, bar].baz in qux);', { testFail("var f;\nfunction f() {}", "Identifier 'f' has already been declared (2:9)", {ecmaVersion: 6, sourceType: "module"}); test("function f() { var x; function x() {} }", {}, {ecmaVersion: 6, sourceType: "module"}) + +test("a.of / 2", {}, {ecmaVersion: 6})