From 72a81021e1ceba38f95a19548fe7c91ff93abf55 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Sat, 19 Sep 2020 19:07:44 -0400 Subject: [PATCH] [[FIX]] Correct interpretation of ImportSpecifier --- src/jshint.js | 11 ++++------- tests/test262/expectations.txt | 2 -- tests/unit/core.js | 6 ++++++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/jshint.js b/src/jshint.js index b9570c41ff..bbcedb4f4a 100644 --- a/src/jshint.js +++ b/src/jshint.js @@ -5581,15 +5581,12 @@ var JSHINT = (function() { break; } var importName; - if (state.tokens.next.type === "default") { - importName = "default"; - advance("default"); - } else { - importName = identifier(context); - } - if (state.tokens.next.value === "as") { + if (peek().value === "as") { + identifier(context, true); advance("as"); importName = identifier(context); + } else { + importName = identifier(context); } // Import bindings are immutable (see ES6 8.1.1.5.5) diff --git a/tests/test262/expectations.txt b/tests/test262/expectations.txt index 1a4ea5b7d9..958ca9e4f7 100644 --- a/tests/test262/expectations.txt +++ b/tests/test262/expectations.txt @@ -161,8 +161,6 @@ test/language/module-code/early-export-global.js(default) test/language/module-code/early-export-global.js(strict mode) test/language/module-code/early-export-unresolvable.js(default) test/language/module-code/early-export-unresolvable.js(strict mode) -test/language/module-code/instn-named-id-name.js(default) -test/language/module-code/instn-named-id-name.js(strict mode) test/language/module-code/parse-err-hoist-lex-fun.js(default) test/language/module-code/parse-err-hoist-lex-fun.js(strict mode) test/language/module-code/parse-err-hoist-lex-gen.js(default) diff --git a/tests/unit/core.js b/tests/unit/core.js index fe7e305cc9..2bc5f8f40d 100644 --- a/tests/unit/core.js +++ b/tests/unit/core.js @@ -990,6 +990,12 @@ exports.testES6Modules = function (test) { "export default async function * () { yield 0; await 0; }", ], { esversion: 9, module: true }); + TestRun(test, "IdentifierName in renamed import/export") + .test([ + "import { if as x } from '.';", + "export { x as if } from '.';" + ], { esversion: 6, module: true }); + test.done(); };