Modules might be in loose mode when checking for undecl exports (#9725)

This commit is contained in:
Nicolò Ribaudo
2019-03-21 01:57:12 +01:00
committed by Daniel Tschinder
parent 7f8ded9851
commit 2201fd839b
4 changed files with 167 additions and 2 deletions

View File

@@ -139,10 +139,13 @@ export default class ScopeHandler {
}
checkLocalExport(id: N.Identifier) {
// scope.functions must be empty as Module code is always strict.
if (
this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
this.scopeStack[0].var.indexOf(id.name) === -1
this.scopeStack[0].var.indexOf(id.name) === -1 &&
// In strict mode, scope.functions will always be empty.
// Modules are strict by default, but the `scriptMode` option
// can overwrite this behavior.
this.scopeStack[0].functions.indexOf(id.name) === -1
) {
this.undefinedExports.set(id.name, id.start);
}