-
-
Notifications
You must be signed in to change notification settings - Fork 803
feat(parser): improve diagnostic messages for merge conflicts #15443
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
Merged
graphite-app
merged 1 commit into
main
from
c/11-04-feat_parser_improve_diagnostic_messages_for_merge_conflicts
Nov 8, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Test case for git conflict markers detection | ||
| // Based on https://github.com/rust-lang/rust/pull/106242 | ||
| // | ||
| // NOTE: Parser stops at the first conflict marker encountered (fatal error), | ||
| // so only the first conflict in this file will be reported. | ||
| // Subsequent conflicts are included for completeness but won't be tested | ||
| // until the earlier conflicts are removed. | ||
|
|
||
| function test() { | ||
| <<<<<<< HEAD | ||
| const x = 1; | ||
| ======= | ||
| const y = 2; | ||
| >>>>>>> branch | ||
| return x; | ||
| } | ||
|
|
||
| // Test with diff3 format | ||
| function test2() { | ||
| <<<<<<< HEAD | ||
| const a = 1; | ||
| ||||||| parent | ||
| const b = 2; | ||
| ======= | ||
| const c = 3; | ||
| >>>>>>> branch | ||
| return a; | ||
| } | ||
|
|
||
| // Test in enum/object-like structure | ||
| const obj = { | ||
| <<<<<<< HEAD | ||
| x: 1, | ||
| ======= | ||
| y: 2; | ||
| >>>>>>> branch | ||
| }; | ||
|
|
||
| // Test incomplete conflict (only start marker) | ||
| function test3() { | ||
| <<<<<<< HEAD | ||
| const incomplete = true; | ||
| return incomplete; | ||
| } | ||
|
|
||
| // Test nested conflicts (only outermost conflict will be detected) | ||
| function nested() { | ||
| <<<<<<< OUTER | ||
| const outer = 1; | ||
| <<<<<<< INNER | ||
| const inner = 2; | ||
| ======= | ||
| const innerAlt = 3; | ||
| >>>>>>> INNER | ||
| ======= | ||
| const outerAlt = 4; | ||
| >>>>>>> OUTER | ||
| } | ||
|
|
||
| // Test different lexer contexts for >>>>>>> | ||
| // Context 1: After expression (may lex as ShiftRight3 + ShiftRight3 + RAngle) | ||
| const expr = a | ||
| >>>>>>> branch | ||
|
|
||
| // Context 2: At statement start (may lex as individual RAngle tokens) | ||
| >>>>>>> branch | ||
|
|
||
| // Context 3: After binary operator (may lex as ShiftRight + ShiftRight + ShiftRight + RAngle) | ||
| const x = 1 >> | ||
| >>>>>>> branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Test that conflict markers in strings and comments don't trigger false positives | ||
| // These should all parse successfully as they are valid JavaScript code | ||
|
|
||
| // Conflict markers in strings (should NOT trigger) | ||
| const validString = "<<<<<<< HEAD"; | ||
| const anotherString = "======="; | ||
| const endMarker = ">>>>>>> branch"; | ||
| const diff3Marker = "|||||||"; | ||
|
|
||
| // Conflict markers in template literals (should NOT trigger) | ||
| const validTemplate = ` | ||
| <<<<<<< not a marker | ||
| this is fine | ||
| ======= | ||
| still fine | ||
| >>>>>>> also fine | ||
| `; | ||
|
|
||
| // Conflict markers in comments (should NOT trigger) | ||
| // <<<<<<< HEAD - this is a comment about conflicts | ||
| // ======= separator | ||
| // >>>>>>> branch | ||
|
|
||
| /* | ||
| Multi-line comment with markers: | ||
| <<<<<<< HEAD | ||
| ======= | ||
| >>>>>>> branch | ||
| These are all just text in a comment | ||
| */ | ||
|
|
||
| // Edge case: markers that look similar but aren't exactly 7 characters | ||
| // These should NOT trigger because they're not conflict markers | ||
| const tooShort = "<<<<<<"; | ||
| const tooLong = "<<<<<<<<"; | ||
|
|
||
| // All of the above should parse successfully | ||
| export { validString, validTemplate }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| codegen_misc Summary: | ||
| AST Parsed : 48/48 (100.00%) | ||
| Positive Passed: 48/48 (100.00%) | ||
| AST Parsed : 49/49 (100.00%) | ||
| Positive Passed: 49/49 (100.00%) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| formatter_misc Summary: | ||
| AST Parsed : 48/48 (100.00%) | ||
| Positive Passed: 48/48 (100.00%) | ||
| AST Parsed : 49/49 (100.00%) | ||
| Positive Passed: 49/49 (100.00%) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.