Skip to content

JS Crash: global type reference to constructor function #32997

Closed

Description

From chrome-devtools-frontend's failure in #32991:

// @Filename: test.js
var SDK = {}
SDK.SourceMap = function () { }
SDK.SourceMap.prototype = { compiledURL() {} }

// @Filename: other.js
/**
 * @param {SDK.SourceMap} sourceMap
 */
function no(sourceMap) {
  return sourceMap.wat
}

Expected behavior:
no crash and a bunch of errors

Actual behavior:
assert from merging a symbol into itself. it looks like both the function () {} and SDK.SourceMap lhs of assignment get the prototype method in the binder.

Activity

  1. sandersn commented on Aug 20, 2019

    @sandersn
    MemberAuthor

    Looks like we don't cache correctly and try to merge into the same symbol twice.

  2. sandersn commented on Aug 20, 2019

    @sandersn
    MemberAuthor

    Welp Wesley Wigham (@weswigham), looks like I found a reason I need caching in mergeJSSymbols; you'll often want to get the type and declaredType both from a symbol, and both code paths call mergeJSSymbols. We want to avoid double-merging any particular symbol into the combined symbol.

  3. weswigham commented on Aug 20, 2019

    @weswigham
    Member

    Thereeeeeeee we go. I figured there had to be a reason. XD

  4. sandersn commented on Aug 21, 2019

    @sandersn
    MemberAuthor

    Also, bonus crash, if you leave out compiledURL then the cloned target doesn't get an empty map for members and crashes in getIndexType.

  5. added
    BugA bug in TypeScript
    CrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
    Fix AvailableA PR has been opened for this issue
    on Aug 21, 2019
  6. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions