| 1 |
# This test exercises an edge case of merging. |
| 2 |
# |
| 3 |
# Two analyzers generate overlapping fixes for this package: |
| 4 |
# - 'rename' changes "bar" to "baz" |
| 5 |
# - 'marker' changes "ar" to "baz" |
| 6 |
# Historically this used to cause a conflict, but as it happens, |
| 7 |
# the new merge algorithm splits the rename fix, since it overlaps |
| 8 |
# the marker fix, into two subedits: |
| 9 |
# - a deletion of "b" and |
| 10 |
# - an edit from "ar" to "baz". |
| 11 |
# The deletion is of course nonoverlapping, and the edit, |
| 12 |
# by happy chance, is identical to the marker fix, so the two |
| 13 |
# are coalesced. |
| 14 |
# |
| 15 |
# (This is a pretty unlikely situation, but it corresponds |
| 16 |
# to a historical test, TestOther, that used to check for |
| 17 |
# a conflict, and it seemed wrong to delete it without explanation.) |
| 18 |
# |
| 19 |
# The fixes are silently and successfully applied. |
| 20 |
|
| 21 |
checker -rename -marker -fix -v example.com/a |
| 22 |
stderr applied 2 fixes, updated 1 file |
| 23 |
exit 0 |
| 24 |
|
| 25 |
-- go.mod -- |
| 26 |
module example.com |
| 27 |
go 1.22 |
| 28 |
|
| 29 |
-- a/a.go -- |
| 30 |
package a |
| 31 |
|
| 32 |
func f(bar int) {} //@ fix("ar", "baz") |
| 33 |
|
| 34 |
-- want/a/a.go -- |
| 35 |
package a |
| 36 |
|
| 37 |
func f(baz int) {} //@ fix("ar", "baz") |