From a3157401658db718c1659a05ee29f758b3df7318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 27 Oct 2020 13:21:11 +0100 Subject: [PATCH 1/2] assert,repl: enable ecmaVersion 2021 in acorn parser This adds support for the new logical assignment operators. --- lib/assert.js | 2 +- lib/internal/repl/await.js | 2 +- lib/internal/repl/utils.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index 49143d64466f57..5256b9233365f8 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -240,7 +240,7 @@ function parseCode(code, offset) { // Parse the read code until the correct expression is found. do { try { - node = parseExpressionAt(code, start, { ecmaVersion: 11 }); + node = parseExpressionAt(code, start, { ecmaVersion: 2021 }); start = node.end + 1 || start; // Find the CallExpression in the tree. node = findNodeAround(node, offset, 'CallExpression'); diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js index 7bfdcb894f3045..e93de5487ebd45 100644 --- a/lib/internal/repl/await.js +++ b/lib/internal/repl/await.js @@ -90,7 +90,7 @@ function processTopLevelAwait(src) { const wrappedArray = wrapped.split(''); let root; try { - root = parser.parse(wrapped, { ecmaVersion: 11 }); + root = parser.parse(wrapped, { ecmaVersion: 2021 }); } catch { return null; } diff --git a/lib/internal/repl/utils.js b/lib/internal/repl/utils.js index 7d68e5e4d99178..150411a9d9df4b 100644 --- a/lib/internal/repl/utils.js +++ b/lib/internal/repl/utils.js @@ -114,7 +114,7 @@ function isRecoverableError(e, code) { // Try to parse the code with acorn. If the parse fails, ignore the acorn // error and return the recoverable status. try { - RecoverableParser.parse(code, { ecmaVersion: 11 }); + RecoverableParser.parse(code, { ecmaVersion: 2021 }); // Odd case: the underlying JS engine (V8, Chakra) rejected this input // but Acorn detected no issue. Presume that additional text won't From 089c47911be2a75c750c35b9cf836b4f78bbf841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 28 Oct 2020 14:01:30 +0100 Subject: [PATCH 2/2] fixup! assert,repl: enable ecmaVersion 2021 in acorn parser Co-authored-by: Ruben Bridgewater --- lib/assert.js | 2 +- lib/internal/repl/await.js | 2 +- lib/internal/repl/utils.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index 5256b9233365f8..fbed26925512f5 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -240,7 +240,7 @@ function parseCode(code, offset) { // Parse the read code until the correct expression is found. do { try { - node = parseExpressionAt(code, start, { ecmaVersion: 2021 }); + node = parseExpressionAt(code, start, { ecmaVersion: 'latest' }); start = node.end + 1 || start; // Find the CallExpression in the tree. node = findNodeAround(node, offset, 'CallExpression'); diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js index e93de5487ebd45..da6c7a3a17da99 100644 --- a/lib/internal/repl/await.js +++ b/lib/internal/repl/await.js @@ -90,7 +90,7 @@ function processTopLevelAwait(src) { const wrappedArray = wrapped.split(''); let root; try { - root = parser.parse(wrapped, { ecmaVersion: 2021 }); + root = parser.parse(wrapped, { ecmaVersion: 'latest' }); } catch { return null; } diff --git a/lib/internal/repl/utils.js b/lib/internal/repl/utils.js index 150411a9d9df4b..058f262b5a6b47 100644 --- a/lib/internal/repl/utils.js +++ b/lib/internal/repl/utils.js @@ -114,7 +114,7 @@ function isRecoverableError(e, code) { // Try to parse the code with acorn. If the parse fails, ignore the acorn // error and return the recoverable status. try { - RecoverableParser.parse(code, { ecmaVersion: 2021 }); + RecoverableParser.parse(code, { ecmaVersion: 'latest' }); // Odd case: the underlying JS engine (V8, Chakra) rejected this input // but Acorn detected no issue. Presume that additional text won't