[compiler] Add snap subcommand to minimize a test input#447
Conversation
Greptile OverviewGreptile SummaryThis PR adds a new Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
|
969b035 to
97d94d6
Compare
| "@babel/code-frame": "^7.22.5", | ||
| "@babel/generator": "^7.19.1", |
There was a problem hiding this comment.
conflicting @babel/generator versions - dependency requests ^7.19.1 but resolution forces 7.2.0
| "@babel/code-frame": "^7.22.5", | |
| "@babel/generator": "^7.19.1", | |
| "@babel/code-frame": "^7.22.5", | |
| "@babel/generator": "^7.2.0", |
Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/snap/package.json
Line: 24:25
Comment:
conflicting `@babel/generator` versions - dependency requests `^7.19.1` but resolution forces `7.2.0`
```suggestion
"@babel/code-frame": "^7.22.5",
"@babel/generator": "^7.2.0",
```
How can I resolve this? If you propose a fix, please make it concise.| // Read the input file | ||
| const input = fs.readFileSync(inputPath, 'utf-8'); | ||
| const filename = path.basename(inputPath); | ||
| const firstLine = input.substring(0, input.indexOf('\n')); |
There was a problem hiding this comment.
potential issue if file contains no newline - indexOf('\n') returns -1, causing substring(0, -1) to return empty string
| const firstLine = input.substring(0, input.indexOf('\n')); | |
| const firstLine = input.includes('\n') ? input.substring(0, input.indexOf('\n')) : input; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/snap/src/minimize.ts
Line: 2039:2039
Comment:
potential issue if file contains no newline - `indexOf('\n')` returns -1, causing `substring(0, -1)` to return empty string
```suggestion
const firstLine = input.includes('\n') ? input.substring(0, input.indexOf('\n')) : input;
```
How can I resolve this? If you propose a fix, please make it concise.| return {kind: 'parse_error', message: (e as Error).message}; | ||
| } | ||
|
|
||
| const firstLine = code.substring(0, code.indexOf('\n')); |
There was a problem hiding this comment.
same issue - if code has no newline, indexOf('\n') returns -1
| const firstLine = code.substring(0, code.indexOf('\n')); | |
| const firstLine = code.includes('\n') ? code.substring(0, code.indexOf('\n')) : code; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/snap/src/minimize.ts
Line: 49:49
Comment:
same issue - if `code` has no newline, `indexOf('\n')` returns -1
```suggestion
const firstLine = code.includes('\n') ? code.substring(0, code.indexOf('\n')) : code;
```
How can I resolve this? If you propose a fix, please make it concise.|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35663
Original author: josephsavona
Snap now supports subcommands 'test' (default) and 'minimize`. The minimize subcommand attempts to minimize a single failing input fixture by incrementally simplifying the ast so long as the same error occurs. I spot-checked it and it seemed to work pretty well. This is intended for use in a new subagent designed for investigating bugs — fixture simplification is an important part of the process and we can automate this rather than light tokens on fire.
Example Input:
Command output:
This demonstrates things like: