Skip to content

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

Closed
@sandersn

Description

@sandersn
// @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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions