Skip to content
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

In JS, out-of-order prototype assignments crash in the binder #22725

Closed
sandersn opened this issue Mar 20, 2018 · 1 comment
Closed

In JS, out-of-order prototype assignments crash in the binder #22725

sandersn opened this issue Mar 20, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

// @allowJs: true
// @checkJs: true
// @noEmit: true
// @filename: a.js
OOOrder.prototype.m = function () {
    this.p = 1
}
function OOOrder() {
    this.x = 1
}

Expected behavior:
No crash, and OOOrder has instance type { p: number | undefined, x: number }

Actual behavior:
Crash in the binder trying to add p to OOOrder: constructorSymbol.members = constructorSymbol.members || createSymbolTable(); when constructorSymbol isn't defined.

Before #22643, this incorrectly added p to the instance of m, which is incorrect. So falling back to the old behaviour isn't a good option. Instead it needs the same created-nested-namespace logic as bindPropertyAssignment and bindExportsPropertyAssignment.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Mar 20, 2018
@sandersn
Copy link
Member Author

This is best fixed by binding functions first, which will fix a lot of related bugs I found while surveying popular javascript packages.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants