cmd/vet: internal error: no range for "n" #26725
Comments
vetshadow not works, so enable it. Update golang/go#26725 Update #538
Also happens with 1.10 so not a regression; setting milestone to 1.12. |
Simpler reproduction case: package p
func F(x interface{}) int {
switch v := x.(type) {
case int, int32:
if v, ok := x.(int); ok {
return v
}
case int64:
return int(v)
}
return 0
} |
The error has happened since 1.5, when vet was added to the Go release. |
I think the bug is that for a variable defined in a type switch statement the go/types package returns it with a CC @griesemer |
@ianlancetaylor That object is introduced implicitly for each type switch case clause; it is found in the Implicits map. |
Change https://golang.org/cl/135117 mentions this issue: |
For type switches using a short variable declaration of the form switch t := x.(type) { case T1: ... go/types doesn't declare the symbolic variable (t in this example) with the switch; thus such variables are not found in types.Info.Defs. Instead they are implicitly declared with each type switch case, and can be found in types.Info.Implicits. Adjust the shadowing code accordingly. Added a test case to verify that the issue is fixed, and a test case verifying that the shadowing code now considers implicitly declared variables introduces in type switch cases. While at it, also fixed the (internal) error reporting to provide more accurate information. Fixe #26725. Change-Id: If408ed9e692bf47c640f81de8f46bf5eb43415b0 Reviewed-on: https://go-review.googlesource.com/135117 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Alan Donovan <adonovan@google.com>
This was fixed by https://golang.org/cl/135117, but the respective commit message contained a typo in the "Fixes ..." line and thus didn't auto-close this issue. Closing now. |
go version devel +ce06f5a222 Tue Jul 31 18:11:29 2018 +0000 linux/amd64
Checkout google/syzkaller@8ef497b
The text was updated successfully, but these errors were encountered: