Skip to content

Debug Failure in invalid JSDoc type expression #47537

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

Closed
gabritto opened this issue Jan 21, 2022 · 2 comments · Fixed by #52710
Closed

Debug Failure in invalid JSDoc type expression #47537

gabritto opened this issue Jan 21, 2022 · 2 comments · Fixed by #52710
Assignees
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue Old-Crawler-Detected Detected by an older crawler (aka "fuzzer") running random TSServer operations on public code. Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@gabritto
Copy link
Member

Bug Report

If we have invalid JSDoc like in the example below, we get a Debug Failure. Did not expect TypeLiteral to have an Identifier in its trivia when calling service functions e.g. getSyntacticClassifications on a span containing the bad jsdoc.

🔎 Search Terms

debug failure, Did not expect TypeLiteral to have an Identifier in its trivia

🕗 Version & Regression Information

Probably always.

This is a crash.

⏯ Playground Link

Playground link with relevant code

💻 Code

class I18n {
   /**
    * @param {{dot|fulltext}} [stringMode] - which mode our translation keys use
    */
   constructor(options = {}) {}
}

The bad JSDoc is the part inside the param's type expression: {dot|fulltext}.

🙁 Actual behavior

Crash:

| Error: Debug Failure. Did not expect TypeLiteral to have an Identifier in its trivia
|     at addSyntheticNodes (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160370:30)
|     at createSyntaxList (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160386:13)
|     at processNodes (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160349:27)
|     at visitNodes (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:29926:24)
|     at Object.forEachChild (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:30066:24)
|     at NodeObject.forEachChild (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160324:23)
|     at createChildren (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160358:14)
|     at NodeObject.getChildren (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:160301:56)
|     at processElement (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:128482:47)
|     at processElement (C:\Users\gabrielaa\projects\tsserverfuzzer\node_modules\typescript\lib\tsserverlibrary.js:128486:25)

🙂 Expected behavior

No crash.

@gabritto gabritto self-assigned this Jan 21, 2022
@gabritto
Copy link
Member Author

For some context on why we have this debug assertion, see #44154.

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output labels Jan 21, 2022
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 4.6.1 milestone Jan 21, 2022
@DanielRosenwasser
Copy link
Member

Looks like another one with

/**
 * @type {{
 *      prop: SomeType - lol I think I can comment here
 * }}
 */
var someVar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Crash For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output Fix Available A PR has been opened for this issue Old-Crawler-Detected Detected by an older crawler (aka "fuzzer") running random TSServer operations on public code. Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
5 participants