-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/cover: panic: overlapping edits #23927
Comments
/cc @ianlancetaylor |
Can you tell us how to recreate the problem? |
Actually i have 340 packages with tests and only one is having this issue. It seems the file is not different from the others. I still have to identify what's causing the issue or how to replicate it. I'll let you know very soon. |
I worked and found what's causing the issue. I have this function (it is only an example but it's recreating the issue). With the function below I don't have the issue:
but when I add the else the issue appears:
|
I was able to replicate the issue with this code too:
|
with this code works:
It seems the issue is in somewhere in the ELSE clause handler |
Thanks. For clarity, can you show us a complete, self-contained example, along with the commands you use to recreate the problem? That would save time on our end. Thanks. |
Atttached .go file and its related tests. It is veri very very very simple but it reproduce the issue. Let me know |
Thanks. The problem only arises because your main.go file has not been through gofmt. If I run gofmt on the file, the problem disappears. The problem is specifically main.go: package main
func main(){
var attributes []string
var item interface{}
if len(attributes) > 0{
if item != nil{
//DO SOMETHING
}
}else{
//DO SOMETHING
}
} main_test.go: package main
import (
"testing"
)
func TestMain(t *testing.T) {
main()
} go test -cover
|
😮 got it |
Change https://golang.org/cl/98935 mentions this issue: |
CL 98935 OK for Go 1.10.1 |
Change https://golang.org/cl/102786 mentions this issue: |
Without the change to cover.go, the new test fails with panic: overlapping edits: [4946,4950)->"", [4947,4947)->"thisNameMustBeVeryLongToCauseOverflowOfCounterIncrementStatementOntoNextLineForTest.Count[112]++;" The original code inserts "else{", deletes "else", and then positions a new block just after the "}" that must come before the "else". That works on gofmt'ed code, but fails if the code looks like "}else". When there is no space between the "{" and the "else", the new block is inserted into a location that we are deleting, leading to the "overlapping edits" mentioned above. This CL fixes this case by not deleting the "else" but just using the one that is already there. That requires adjust the block offset to come after the "{" that we insert. Fixes #23927 Change-Id: I40ef592490878765bbce6550ddb439e43ac525b2 Reviewed-on: https://go-review.googlesource.com/98935 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-on: https://go-review.googlesource.com/102786 Run-TryBot: Andrew Bonventre <andybons@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
I had this problem with go 1.10.3 |
@AgustinBanchio if you test without GoLand can you still reproduce the issue? |
@AgustinBanchio This problem is fixed in 1.10.1. If you are seeing the exact same problem, then you are most likely running an older version of the toolchain. If you are sure that you are not, then you have found a different problem. Please open a new issue with reproduction instructions. Thanks. |
Hello all with the latest RC if i run tests all is ok, if I run them with coverage I run into this error:
The text was updated successfully, but these errors were encountered: