From 2b229f0ac9750aa2643e58b5e0c0448d7d9c8363 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Sat, 17 Feb 2018 13:52:17 +0900 Subject: [PATCH] follow tc39/ecma262#1102 --- src/regexp.js | 5 +++-- test/tests-regexp-2018.js | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/regexp.js b/src/regexp.js index 96ef9212e..cb4935815 100644 --- a/src/regexp.js +++ b/src/regexp.js @@ -289,15 +289,16 @@ pp.validateRegExp_eatAssertion = function(state) { // Lookahead / Lookbehind if (state.eat(LEFT_PARENTHESIS) && state.eat(QUESTION_MARK)) { + let lookbehind = false if (this.options.ecmaVersion >= 9) { - state.eat(LESS_THAN_SIGN) + lookbehind = state.eat(LESS_THAN_SIGN) } if (state.eat(EQUALS_SIGN) || state.eat(EXCLAMATION_MARK)) { this.validateRegExp_disjunction(state) if (!state.eat(RIGHT_PARENTHESIS)) { state.raise("Unterminated group") } - state.lastAssertionIsQuantifiable = true + state.lastAssertionIsQuantifiable = !lookbehind return true } } diff --git a/test/tests-regexp-2018.js b/test/tests-regexp-2018.js index 1add3a75e..0a48fabb7 100644 --- a/test/tests-regexp-2018.js +++ b/test/tests-regexp-2018.js @@ -118,23 +118,23 @@ testFail("/(?\\w){3})f/u", {}, { ecmaVersion: 2018 }) test("/((?<=\\w{3}))f/u", {}, { ecmaVersion: 2018 })