diff --git a/tsc/internal/scanner/scanner.go b/tsc/internal/scanner/scanner.go index 785fe50a4e7df..c264974b62ae2 100644 --- a/tsc/internal/scanner/scanner.go +++ b/tsc/internal/scanner/scanner.go @@ -198,6 +198,11 @@ var textToToken = func() map[string]ast.Kind { return m }() +type ConflictState struct { + markerLength int + scanNextSnapshot bool +} + type ScannerState struct { pos int // Current position in text (and ending position of current token) fullStartPos int // Starting position of current token including preceding whitespace @@ -207,6 +212,7 @@ type ScannerState struct { tokenFlags ast.TokenFlags // Flags for current token commentDirectives []ast.CommentDirective skipJSDocLeadingAsterisks int // Leading asterisks to skip when scanning types inside JSDoc. Should be 0 outside JSDoc + conflictState *ConflictState } type Scanner struct { @@ -530,6 +536,15 @@ func (s *Scanner) Scan() ast.Kind { case '`': s.token = s.scanTemplateAndSetTokenValue(false /*shouldEmitInvalidEscapeError*/) case '%': + if s.charAt(1) == '%' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) + if s.skipTrivia { + continue + } else { + s.token = ast.KindConflictMarkerTrivia + return s.token + } + } if s.charAt(1) == '=' { s.pos += 2 s.token = ast.KindPercentEqualsToken @@ -584,6 +599,15 @@ func (s *Scanner) Scan() ast.Kind { s.token = ast.KindAsteriskToken } case '+': + if s.charAt(1) == '+' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) + if s.skipTrivia { + continue + } else { + s.token = ast.KindConflictMarkerTrivia + return s.token + } + } next := s.charAt(1) if next == '=' { s.pos += 2 @@ -599,6 +623,15 @@ func (s *Scanner) Scan() ast.Kind { s.pos++ s.token = ast.KindCommaToken case '-': + if s.charAt(1) == '-' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) + if s.skipTrivia { + continue + } else { + s.token = ast.KindConflictMarkerTrivia + return s.token + } + } next := s.charAt(1) if next == '=' { s.pos += 2 @@ -764,8 +797,8 @@ func (s *Scanner) Scan() ast.Kind { s.pos++ s.token = ast.KindSemicolonToken case '<': - if s.charAt(1) == '<' && isConflictMarkerTrivia(s.text, s.pos) { - s.pos = scanConflictMarkerTrivia(s.text, s.pos, s.errorAt) + if s.charAt(1) == '<' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) if s.skipTrivia { continue } else { @@ -792,8 +825,8 @@ func (s *Scanner) Scan() ast.Kind { s.token = ast.KindLessThanToken } case '=': - if s.charAt(1) == '=' && isConflictMarkerTrivia(s.text, s.pos) { - s.pos = scanConflictMarkerTrivia(s.text, s.pos, s.errorAt) + if s.charAt(1) == '=' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) if s.skipTrivia { continue } else { @@ -817,8 +850,8 @@ func (s *Scanner) Scan() ast.Kind { s.token = ast.KindEqualsToken } case '>': - if s.charAt(1) == '>' && isConflictMarkerTrivia(s.text, s.pos) { - s.pos = scanConflictMarkerTrivia(s.text, s.pos, s.errorAt) + if s.charAt(1) == '>' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) if s.skipTrivia { continue } else { @@ -862,8 +895,8 @@ func (s *Scanner) Scan() ast.Kind { s.pos++ s.token = ast.KindOpenBraceToken case '|': - if s.charAt(1) == '|' && isConflictMarkerTrivia(s.text, s.pos) { - s.pos = scanConflictMarkerTrivia(s.text, s.pos, s.errorAt) + if s.charAt(1) == '|' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) if s.skipTrivia { continue } else { @@ -896,6 +929,15 @@ func (s *Scanner) Scan() ast.Kind { s.pos++ s.token = ast.KindAtToken case '\\': + if s.charAt(1) == '\\' && isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) + if s.skipTrivia { + continue + } else { + s.token = ast.KindConflictMarkerTrivia + return s.token + } + } if s.scanIdentifier(0, identifierVariantStandard) { s.token = GetIdentifierToken(s.tokenValue) } else { @@ -1276,8 +1318,8 @@ func (s *Scanner) ScanJsxTokenEx(allowMultilineJsxText bool) ast.Kind { break } if ch == '<' { - if isConflictMarkerTrivia(s.text, s.pos) { - s.pos = scanConflictMarkerTrivia(s.text, s.pos, s.errorAt) + if isConflictMarkerTrivia(s.text, s.pos, s.conflictState) { + s.pos, s.conflictState = scanConflictMarkerTrivia(s.text, s.pos, s.conflictState, s.errorAt) s.token = ast.KindConflictMarkerTrivia return s.token } @@ -2282,22 +2324,6 @@ func GetViableKeywordSuggestions() []string { return result } -func couldStartTrivia(text string, pos int) bool { - // Keep in sync with skipTrivia - switch ch := text[pos]; ch { - // Characters that could start normal trivia - case '\r', '\n', '\t', '\v', '\f', ' ', '/', - // Characters that could start conflict marker trivia - '<', '|', '=', '>': - return true - case '#': - // Only if its the beginning can we have #! trivia - return pos == 0 - default: - return ch > maxAsciiCharacter - } -} - type SkipTriviaOptions struct { StopAfterLineBreak bool StopAtComments bool @@ -2318,7 +2344,7 @@ func SkipTriviaEx(text string, pos int, options *SkipTriviaOptions) int { textLen := len(text) canConsumeStar := false - // Keep in sync with couldStartTrivia + var conflictState *ConflictState for { if pos >= textLen { return pos @@ -2371,9 +2397,9 @@ func SkipTriviaEx(text string, pos int, options *SkipTriviaOptions) int { continue } } - case '<', '|', '=', '>': - if isConflictMarkerTrivia(text, pos) { - pos = scanConflictMarkerTrivia(text, pos, nil) + case '<', '|', '=', '%', '\\', '+', '-', '>': + if isConflictMarkerTrivia(text, pos, conflictState) { + pos, conflictState = scanConflictMarkerTrivia(text, pos, conflictState, nil) canConsumeStar = false continue } @@ -2399,21 +2425,21 @@ func SkipTriviaEx(text string, pos int, options *SkipTriviaOptions) int { } } -// All conflict markers consist of the same character repeated seven times. If it is -// a <<<<<<< or >>>>>>> marker then it is also followed by a space. +// All conflict markers consist of the same character repeated seven or more times, +// followed by either a space or a newline. var ( - mergeConflictMarkerLength = len("<<<<<<<") - maxAsciiCharacter byte = 127 + mergeConflictMarkerMinLength = len("<<<<<<<") + maxAsciiCharacter byte = 127 ) -func isConflictMarkerTrivia(text string, pos int) bool { +func isConflictMarkerTrivia(text string, pos int, conflictState *ConflictState) bool { if pos < 0 { panic("pos < 0") } - // Fast reject: a conflict marker is the same byte repeated seven times. If the - // second byte differs (the overwhelmingly common case for `<`, `>`, `=`, `|` - // tokens), it cannot be a marker, so skip the line-start check entirely. + // Fast reject: a conflict marker is the same byte repeated at least seven times. If + // the second byte differs (the overwhelmingly common case), it cannot be a marker, so + // skip the line-start check entirely. if pos+1 >= len(text) || text[pos+1] != text[pos] { return false } @@ -2424,52 +2450,112 @@ func isConflictMarkerTrivia(text string, pos int) bool { prev, _ := utf8.DecodeLastRuneInString(text[:pos-2]) atLineStart = stringutil.IsLineBreak(prev) } - if atLineStart { - ch := text[pos] + if !atLineStart { + return false + } - if (pos + mergeConflictMarkerLength) < len(text) { - for i := range mergeConflictMarkerLength { - if text[pos+i] != ch { - return false - } - } + ch := text[pos] + length := 0 + for pos+length < len(text) && text[pos+length] == ch { + length += 1 + } - return ch == '=' || text[pos+mergeConflictMarkerLength] == ' ' - } + if length < mergeConflictMarkerMinLength { + return false + } + + if conflictState != nil && length != conflictState.markerLength { + return false + } + + if pos+length >= len(text) { + return true + } + + if text[pos+length] == ' ' { + return true + } + + nextChar, _ := utf8.DecodeRuneInString(text[pos+length:]) + if stringutil.IsLineBreak(nextChar) { + return true } return false } -func scanConflictMarkerTrivia(text string, pos int, reportError func(diag *diagnostics.Message, pos int, length int, args ...any)) int { - if reportError != nil { - reportError(diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength) - } +func scanConflictMarkerTrivia(text string, pos int, conflictState *ConflictState, reportError func(diag *diagnostics.Message, pos int, length int, args ...any)) (int, *ConflictState) { ch, size := utf8.DecodeRuneInString(text[pos:]) length := len(text) - if ch == '<' || ch == '>' { - for pos < length && !stringutil.IsLineBreak(ch) { - pos += size - ch, size = utf8.DecodeRuneInString(text[pos:]) + if ch != '<' && ch != '>' && ch != '|' && ch != '=' && ch != '%' && ch != '\\' && ch != '+' && ch != '-' { + panic("Assertion failed: unexpected marker char") + } + + markerChar := ch + startPos := pos + + // First, consume and measure the marker itself and report the error. + for pos < length && ch == markerChar { + pos += size + ch, size = utf8.DecodeRuneInString(text[pos:]) + } + markerLength := pos - startPos + + if reportError != nil { + reportError(diagnostics.Merge_conflict_marker_encountered, startPos, markerLength) + } + + // Then consume up to and including the next line break. + for pos < length && !stringutil.IsLineBreak(ch) { + pos += size + ch, size = utf8.DecodeRuneInString(text[pos:]) + } + if pos < length && ch == '\r' { + pos += size + ch, size = utf8.DecodeRuneInString(text[pos:]) + } + if pos < length && ch == '\n' { + pos += size + ch, _ = utf8.DecodeRuneInString(text[pos:]) + } + + if markerChar == '<' { + conflictState = new(ConflictState) + conflictState.markerLength = markerLength + + // If the next line starts with a % or + marker, this is a Jujutsu + // conflict and we should remember to scan the next snapshot section. + // Otherwise, it's a Git conflict and we just need to scan the section + // immediately following this marker line. + if (ch == '%' || ch == '+') && isConflictMarkerTrivia(text, pos, conflictState) { + conflictState.scanNextSnapshot = true } - } else { - if ch != '|' && ch != '=' { - panic("Assertion failed: ch must be either '|' or '='") - } - // Consume everything from the start of a ||||||| or ======= marker to the start - // of the next ======= or >>>>>>> marker. - for pos < length { - currentChar := text[pos] - if (currentChar == '=' || currentChar == '>') && rune(currentChar) != ch && isConflictMarkerTrivia(text, pos) { - break - } - pos++ + return pos, conflictState + } + + if markerChar == '+' && conflictState != nil && conflictState.scanNextSnapshot { + nextState := *conflictState + nextState.scanNextSnapshot = false + return pos, &nextState + } + + if markerChar == '>' { + return pos, nil + } + + // Now that we've established we don't want to scan this section, consume + // everything up to the start of the next marker. + for pos < length { + currentChar := text[pos] + if (currentChar == '=' || currentChar == '%' || currentChar == '\\' || currentChar == '+' || currentChar == '-' || currentChar == '>') && isConflictMarkerTrivia(text, pos, conflictState) { + break } + pos++ } - return pos + return pos, conflictState } func isShebangTrivia(text string, pos int) bool { diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.errors.txt b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.errors.txt new file mode 100644 index 0000000000000..2c72161994431 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.errors.txt @@ -0,0 +1,36 @@ +conflictMarkerJujutsuTrivia1.ts(3,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia1.ts(4,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia1.ts(5,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia1.ts(8,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia1.ts(9,6): error TS2304: Cannot find name 'b'. +conflictMarkerJujutsuTrivia1.ts(10,1): error TS1185: Merge conflict marker encountered. + + +==== conflictMarkerJujutsuTrivia1.ts (6 errors) ==== + class C { + foo() { + <<<<<<< conflict 1 of 1 + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + %%%%%%% diff from: puqzxvrm 9be6077e "call c()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + \\\\\\\ to: lnqukurm 3504bbcc "call a()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + - c(); + + a(); + +++++++ uxvuvmmx 392ce8b5 "call b()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + b(); + ~ +!!! error TS2304: Cannot find name 'b'. + >>>>>>> conflict 1 of 1 ends + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + } + + public bar() { } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.js b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.js new file mode 100644 index 0000000000000..be28936aec2b1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia1.ts] //// + +//// [conflictMarkerJujutsuTrivia1.ts] +class C { + foo() { +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +} + + +//// [conflictMarkerJujutsuTrivia1.js] +"use strict"; +class C { + foo() { + b(); + } + bar() { } +} diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.symbols b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.symbols new file mode 100644 index 0000000000000..3c809b9b6fb36 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia1.ts] //// + +=== conflictMarkerJujutsuTrivia1.ts === +class C { +>C : Symbol(C, Decl(conflictMarkerJujutsuTrivia1.ts, 0, 0)) + + foo() { +>foo : Symbol(C.foo, Decl(conflictMarkerJujutsuTrivia1.ts, 0, 9)) + +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +>bar : Symbol(C.bar, Decl(conflictMarkerJujutsuTrivia1.ts, 10, 3)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.types b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.types new file mode 100644 index 0000000000000..defe75611d12a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia1.types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia1.ts] //// + +=== conflictMarkerJujutsuTrivia1.ts === +class C { +>C : C + + foo() { +>foo : () => void + +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>b() : any +>b : any + +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +>bar : () => void +} + diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.errors.txt b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.errors.txt new file mode 100644 index 0000000000000..ca39be0bdcb5b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.errors.txt @@ -0,0 +1,36 @@ +conflictMarkerJujutsuTrivia2.ts(3,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia2.ts(4,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia2.ts(5,6): error TS2304: Cannot find name 'a'. +conflictMarkerJujutsuTrivia2.ts(6,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia2.ts(8,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia2.ts(10,1): error TS1185: Merge conflict marker encountered. + + +==== conflictMarkerJujutsuTrivia2.ts (6 errors) ==== + class C { + foo() { + <<<<<<< conflict 1 of 1 + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + +++++++ lnqukurm 3504bbcc "call a()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + a(); + ~ +!!! error TS2304: Cannot find name 'a'. + ------- puqzxvrm 9be6077e "call c()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + c(); + +++++++ uxvuvmmx 392ce8b5 "call b()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + b(); + >>>>>>> conflict 1 of 1 ends + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + } + + public bar() { } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.js b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.js new file mode 100644 index 0000000000000..29ddc83ba25c7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia2.ts] //// + +//// [conflictMarkerJujutsuTrivia2.ts] +class C { + foo() { +<<<<<<< conflict 1 of 1 ++++++++ lnqukurm 3504bbcc "call a()" + a(); +------- puqzxvrm 9be6077e "call c()" + c(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +} + + +//// [conflictMarkerJujutsuTrivia2.js] +"use strict"; +class C { + foo() { + a(); + } + bar() { } +} diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.symbols b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.symbols new file mode 100644 index 0000000000000..b46465744b193 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia2.ts] //// + +=== conflictMarkerJujutsuTrivia2.ts === +class C { +>C : Symbol(C, Decl(conflictMarkerJujutsuTrivia2.ts, 0, 0)) + + foo() { +>foo : Symbol(C.foo, Decl(conflictMarkerJujutsuTrivia2.ts, 0, 9)) + +<<<<<<< conflict 1 of 1 ++++++++ lnqukurm 3504bbcc "call a()" + a(); +------- puqzxvrm 9be6077e "call c()" + c(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +>bar : Symbol(C.bar, Decl(conflictMarkerJujutsuTrivia2.ts, 10, 3)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.types b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.types new file mode 100644 index 0000000000000..e6cd76ba8b0d6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia2.types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia2.ts] //// + +=== conflictMarkerJujutsuTrivia2.ts === +class C { +>C : C + + foo() { +>foo : () => void + +<<<<<<< conflict 1 of 1 ++++++++ lnqukurm 3504bbcc "call a()" + a(); +>a() : any +>a : any + +------- puqzxvrm 9be6077e "call c()" + c(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +>bar : () => void +} + diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.errors.txt b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.errors.txt new file mode 100644 index 0000000000000..58284d590281b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.errors.txt @@ -0,0 +1,64 @@ +conflictMarkerJujutsuTrivia3.ts(3,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(4,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(5,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(8,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(9,6): error TS2304: Cannot find name 'b'. +conflictMarkerJujutsuTrivia3.ts(10,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(13,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(14,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(15,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(20,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia3.ts(25,1): error TS1185: Merge conflict marker encountered. + + +==== conflictMarkerJujutsuTrivia3.ts (11 errors) ==== + class C { + foo() { + <<<<<<<<<<< conflict 1 of 2 + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + %%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + \\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + - c(); + + a(); + +++++++++++ uxvuvmmx 71bb7e49 "call b()" + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + b(); + ~ +!!! error TS2304: Cannot find name 'b'. + >>>>>>>>>>> conflict 1 of 2 ends + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + } + + <<<<<<<<<<< conflict 2 of 2 + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + %%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + \\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + +/* + +======= + +*/ + + + +++++++++++ uxvuvmmx 71bb7e49 "call b()" + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + /* + %%%%%%% + */ + + >>>>>>>>>>> conflict 2 of 2 ends + ~~~~~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + public bar() { } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.js b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.js new file mode 100644 index 0000000000000..e824b4d23b7a3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia3.ts] //// + +//// [conflictMarkerJujutsuTrivia3.ts] +class C { + foo() { +<<<<<<<<<<< conflict 1 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" +- c(); ++ a(); ++++++++++++ uxvuvmmx 71bb7e49 "call b()" + b(); +>>>>>>>>>>> conflict 1 of 2 ends + } + +<<<<<<<<<<< conflict 2 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" ++/* ++======= ++*/ ++ ++++++++++++ uxvuvmmx 71bb7e49 "call b()" +/* +%%%%%%% +*/ + +>>>>>>>>>>> conflict 2 of 2 ends + public bar() { } +} + + +//// [conflictMarkerJujutsuTrivia3.js] +"use strict"; +class C { + foo() { + b(); + } + bar() { } +} diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.symbols b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.symbols new file mode 100644 index 0000000000000..1c71ab66ae66b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia3.ts] //// + +=== conflictMarkerJujutsuTrivia3.ts === +class C { +>C : Symbol(C, Decl(conflictMarkerJujutsuTrivia3.ts, 0, 0)) + + foo() { +>foo : Symbol(C.foo, Decl(conflictMarkerJujutsuTrivia3.ts, 0, 9)) + +<<<<<<<<<<< conflict 1 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" +- c(); ++ a(); ++++++++++++ uxvuvmmx 71bb7e49 "call b()" + b(); +>>>>>>>>>>> conflict 1 of 2 ends + } + +<<<<<<<<<<< conflict 2 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" ++/* ++======= ++*/ ++ ++++++++++++ uxvuvmmx 71bb7e49 "call b()" +/* +%%%%%%% +*/ + +>>>>>>>>>>> conflict 2 of 2 ends + public bar() { } +>bar : Symbol(C.bar, Decl(conflictMarkerJujutsuTrivia3.ts, 10, 3)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.types b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.types new file mode 100644 index 0000000000000..5fae896395e65 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia3.types @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia3.ts] //// + +=== conflictMarkerJujutsuTrivia3.ts === +class C { +>C : C + + foo() { +>foo : () => void + +<<<<<<<<<<< conflict 1 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" +- c(); ++ a(); ++++++++++++ uxvuvmmx 71bb7e49 "call b()" + b(); +>b() : any +>b : any + +>>>>>>>>>>> conflict 1 of 2 ends + } + +<<<<<<<<<<< conflict 2 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" ++/* ++======= ++*/ ++ ++++++++++++ uxvuvmmx 71bb7e49 "call b()" +/* +%%%%%%% +*/ + +>>>>>>>>>>> conflict 2 of 2 ends + public bar() { } +>bar : () => void +} + diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.errors.txt b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.errors.txt new file mode 100644 index 0000000000000..4d7b1f17faf15 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.errors.txt @@ -0,0 +1,32 @@ +conflictMarkerJujutsuTrivia4.ts(7,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia4.ts(8,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia4.ts(10,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia4.ts(11,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia4.ts(14,1): error TS1185: Merge conflict marker encountered. + + +==== conflictMarkerJujutsuTrivia4.ts (5 errors) ==== + function grapefruit() { + } + + function grape() { + } + + <<<<<<< conflict 1 of 1 + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + +++++++ vqysvltp 86ba33d1 "Change call" (no terminating newline) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + grapefruit() + %%%%%%% diff from: zqvxtwpm 339cbb5a "Add file" (no terminating newline) + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + \\\\\\\ to: noqwrurv d60e161f "Add newline" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + grape() + + + >>>>>>> conflict 1 of 1 ends + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.js b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.js new file mode 100644 index 0000000000000..25641f4fc104c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia4.ts] //// + +//// [conflictMarkerJujutsuTrivia4.ts] +function grapefruit() { +} + +function grape() { +} + +<<<<<<< conflict 1 of 1 ++++++++ vqysvltp 86ba33d1 "Change call" (no terminating newline) +grapefruit() +%%%%%%% diff from: zqvxtwpm 339cbb5a "Add file" (no terminating newline) +\\\\\\\ to: noqwrurv d60e161f "Add newline" + grape() ++ +>>>>>>> conflict 1 of 1 ends + +//// [conflictMarkerJujutsuTrivia4.js] +"use strict"; +function grapefruit() { +} +function grape() { +} +grapefruit(); diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.symbols b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.symbols new file mode 100644 index 0000000000000..3a1c66d410ed9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia4.ts] //// + +=== conflictMarkerJujutsuTrivia4.ts === +function grapefruit() { +>grapefruit : Symbol(grapefruit, Decl(conflictMarkerJujutsuTrivia4.ts, 0, 0)) +} + +function grape() { +>grape : Symbol(grape, Decl(conflictMarkerJujutsuTrivia4.ts, 1, 1)) +} + +<<<<<<< conflict 1 of 1 ++++++++ vqysvltp 86ba33d1 "Change call" (no terminating newline) +grapefruit() +>grapefruit : Symbol(grapefruit, Decl(conflictMarkerJujutsuTrivia4.ts, 0, 0)) + +%%%%%%% diff from: zqvxtwpm 339cbb5a "Add file" (no terminating newline) +\\\\\\\ to: noqwrurv d60e161f "Add newline" + grape() ++ +>>>>>>> conflict 1 of 1 ends diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.types b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.types new file mode 100644 index 0000000000000..0a4e783ccef5e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia4.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia4.ts] //// + +=== conflictMarkerJujutsuTrivia4.ts === +function grapefruit() { +>grapefruit : () => void +} + +function grape() { +>grape : () => void +} + +<<<<<<< conflict 1 of 1 ++++++++ vqysvltp 86ba33d1 "Change call" (no terminating newline) +grapefruit() +>grapefruit() : void +>grapefruit : () => void + +%%%%%%% diff from: zqvxtwpm 339cbb5a "Add file" (no terminating newline) +\\\\\\\ to: noqwrurv d60e161f "Add newline" + grape() ++ +>>>>>>> conflict 1 of 1 ends diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.errors.txt b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.errors.txt new file mode 100644 index 0000000000000..03dc3c2a50d92 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.errors.txt @@ -0,0 +1,36 @@ +conflictMarkerJujutsuTrivia5.ts(3,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia5.ts(4,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia5.ts(5,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia5.ts(8,1): error TS1185: Merge conflict marker encountered. +conflictMarkerJujutsuTrivia5.ts(9,6): error TS2304: Cannot find name 'b'. +conflictMarkerJujutsuTrivia5.ts(10,1): error TS1185: Merge conflict marker encountered. + + +==== conflictMarkerJujutsuTrivia5.ts (6 errors) ==== + class C { + foo() { + <<<<<<< conflict 1 of 1 + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + %%%%%%% diff from: puqzxvrm 9be6077e "call c()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + \\\\\\\ to: lnqukurm 3504bbcc "call a()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + - c(); + + a(); + +++++++ uxvuvmmx 392ce8b5 "call b()" + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + b(); + ~ +!!! error TS2304: Cannot find name 'b'. + >>>>>>> conflict 1 of 1 ends + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + } + + public bar() { } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.js b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.js new file mode 100644 index 0000000000000..a9233b81d6ca4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia5.ts] //// + +//// [conflictMarkerJujutsuTrivia5.ts] +class C { + foo() { +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +} + + +//// [conflictMarkerJujutsuTrivia5.js] +"use strict"; +class C { + foo() { + b(); + } + bar() { } +} diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.symbols b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.symbols new file mode 100644 index 0000000000000..3ba839932c4f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia5.ts] //// + +=== conflictMarkerJujutsuTrivia5.ts === +class C { +>C : Symbol(C, Decl(conflictMarkerJujutsuTrivia5.ts, 0, 0)) + + foo() { +>foo : Symbol(C.foo, Decl(conflictMarkerJujutsuTrivia5.ts, 0, 9)) + +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +>bar : Symbol(C.bar, Decl(conflictMarkerJujutsuTrivia5.ts, 10, 3)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.types b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.types new file mode 100644 index 0000000000000..668f476dcc985 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conflictMarkerJujutsuTrivia5.types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/conflictMarkerJujutsuTrivia5.ts] //// + +=== conflictMarkerJujutsuTrivia5.ts === +class C { +>C : C + + foo() { +>foo : () => void + +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>b() : any +>b : any + +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +>bar : () => void +} + diff --git a/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia1.ts b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia1.ts new file mode 100644 index 0000000000000..9718daf171da2 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia1.ts @@ -0,0 +1,15 @@ +// @target: es2015 +class C { + foo() { +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +} diff --git a/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia2.ts b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia2.ts new file mode 100644 index 0000000000000..951093148f513 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia2.ts @@ -0,0 +1,15 @@ +// @target: es2015 +class C { + foo() { +<<<<<<< conflict 1 of 1 ++++++++ lnqukurm 3504bbcc "call a()" + a(); +------- puqzxvrm 9be6077e "call c()" + c(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +} diff --git a/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia3.ts b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia3.ts new file mode 100644 index 0000000000000..a44386c7c9ac5 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia3.ts @@ -0,0 +1,28 @@ +// @target: es2015 +class C { + foo() { +<<<<<<<<<<< conflict 1 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" +- c(); ++ a(); ++++++++++++ uxvuvmmx 71bb7e49 "call b()" + b(); +>>>>>>>>>>> conflict 1 of 2 ends + } + +<<<<<<<<<<< conflict 2 of 2 +%%%%%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\\\\\ to: lnqukurm 84b1da1d "call a()" ++/* ++======= ++*/ ++ ++++++++++++ uxvuvmmx 71bb7e49 "call b()" +/* +%%%%%%% +*/ + +>>>>>>>>>>> conflict 2 of 2 ends + public bar() { } +} diff --git a/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia4.ts b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia4.ts new file mode 100644 index 0000000000000..2ba314048e932 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia4.ts @@ -0,0 +1,14 @@ +function grapefruit() { +} + +function grape() { +} + +<<<<<<< conflict 1 of 1 ++++++++ vqysvltp 86ba33d1 "Change call" (no terminating newline) +grapefruit() +%%%%%%% diff from: zqvxtwpm 339cbb5a "Add file" (no terminating newline) +\\\\\\\ to: noqwrurv d60e161f "Add newline" + grape() ++ +>>>>>>> conflict 1 of 1 ends \ No newline at end of file diff --git a/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia5.ts b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia5.ts new file mode 100644 index 0000000000000..28ff82ad63edb --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conflictMarkerJujutsuTrivia5.ts @@ -0,0 +1,15 @@ +// @target: es2015 +class C { + foo() { +<<<<<<< conflict 1 of 1 +%%%%%%% diff from: puqzxvrm 9be6077e "call c()" +\\\\\\\ to: lnqukurm 3504bbcc "call a()" +- c(); ++ a(); ++++++++ uxvuvmmx 392ce8b5 "call b()" + b(); +>>>>>>> conflict 1 of 1 ends + } + + public bar() { } +}