Skip to content

Fix getExpandoSymbol for already-expando symbols #36457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2020

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Jan 27, 2020

getExpandoSymbol is intended to get the symbol of the expando in a declaration like

var C = class {
}

However, when this occurs in a module.exports assignment, alias resolution already jumps to the exported symbol -- in this case the expando symbol:

// @filename: first.js
module.exports = class {
}
// @filename: other.js
/* @type {import("./first")} */
var C

getExpandoSymbol is then called on class { } instead of module.exports = class { }.

Previously, getExpandoSymbol would incorrectly treat class { } the same as the export assignment and get the expando ... from the expando
itself. This resulted in merging the expando with itself, which causes bogus errors in webpack and could cause other problems.

Now getExpandoSymbol checks that the declaration is not already an expando.

Fixes #34809

getExpandoSymbol is intended to get the symbol of the expando in a
declaration like

```js
var C = class {
}
```

However, when this occurs in a `module.exports` assignment, alias
resolution already jumps to the exported symbol -- in this case the
expando symbol:

``js
// @filename: first.js
module.exports = class {
}
// @filename: other.js
/* @type {import("./first")} */
var C
```

`getExpandoSymbol` is then called on `class { }` instead of
`module.exports = class { }`.

Previously, `getExpandoSymbol` would incorrectly treat `class { }` the
same as the export assignment and get the expando ... from the expando
itself. This resulted in merging the expando with itself, which causes
bogus errors and could cause other problems.

Now `getExpandoSymbol` checks that the expando "initializer" is
different from the declaration.
Check the declaration directly instead of the initialiser.
@sandersn sandersn merged commit 757e670 into master Jan 27, 2020
@sandersn sandersn deleted the fix-import-type-to-module-exports-of-class-expr branch January 27, 2020 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Circular typedef references causes incorrect error
3 participants