-
Notifications
You must be signed in to change notification settings - Fork 734
Fix various fuzzer-caught crashes in the parser #2038
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
base: main
Are you sure you want to change the base?
Conversation
…introduce new fuzz test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes several parser bugs discovered through fuzz testing, primarily related to edge cases in JSDoc comment parsing and improved await using declaration handling.
- Adds bounds checking to prevent panics when parsing malformed or truncated input
- Improves
@overloadand@satisfiesJSDoc tag support for getter/setter accessors and shorthand properties - Fixes index tracking in list parsing to correctly handle reparsed elements
- Enhances fuzz testing coverage by seeding with compiler test cases
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/parser/utilities.go | Adds bounds checking to prevent out-of-bounds access when filtering JSDoc comment ranges for short comments |
| internal/parser/reparser.go | Adds support for @overload tags on getter/setter accessors, fixes @type tag handling for expressions that may be nil, and properly handles @satisfies tags on shorthand property assignments |
| internal/parser/parser.go | Improves await using declaration detection, adds bounds check to skipTo function, and fixes list element index tracking to account for reparsed items |
| internal/parser/jsdoc.go | Prevents crash when parsing @typedef tags with no property tags by using fallback position |
| internal/ast/parseoptions.go | Exports JSX and Force fields to make them accessible from test package |
| internal/parser/parser_test.go | Converts to external test package, adds comprehensive fuzz test seeding from compiler test cases, and adds helper to parse multi-file test units |
| internal/parser/testdata/fuzz/FuzzParser/* | Adds fuzz test corpus entries that triggered the fixed bugs |
| typeExpression = childTypeTag.TypeExpression | ||
| } else { | ||
| typeExpression = p.finishNode(jsdocTypeLiteral, jsdocPropertyTags[0].Pos()) | ||
| // !!! This differs from Strada but prevents a crash |
Copilot
AI
Nov 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment "This differs from Strada" is unclear. "Strada" is not a term defined in this codebase. This should reference the TypeScript source or be more descriptive about why this differs from the reference implementation.
| // !!! This differs from Strada but prevents a crash | |
| // Note: This diverges from the TypeScript reference implementation (see src/compiler/parser.ts, parseTypedefTag). | |
| // In TypeScript, the typeExpression is not always replaced with a JSDocTypeLiteral here, but in this Go port, | |
| // we assign typeExpression to a new JSDocTypeLiteral to prevent a potential crash when jsdocPropertyTags are present. |
No description provided.