Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

pkg/analysis/importalias: Panic with stdlib import alias #10

Open
ldez opened this issue Feb 27, 2021 · 0 comments
Open

pkg/analysis/importalias: Panic with stdlib import alias #10

ldez opened this issue Feb 27, 2021 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@ldez
Copy link

ldez commented Feb 27, 2021

What steps did you take and what happened:

package a

import (
	wrong_alias "fmt"
	alias_os "os"
)
panic: runtime error: index out of range [-1]

goroutine 2325 [running]:
github.com/projectcontour/lint/pkg/analysis/importalias.getAliasFix(0xc0058f7a90, 0x0, 0x0, 0xc0058f7a90, 0x0)
        /home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:160 +0x1ca
github.com/projectcontour/lint/pkg/analysis/importalias.run.func1(0x73bde0, 0xc0062546f0)
        /home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:96 +0x3f3
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc009fba5e8, 0xc0048beb48, 0x1, 0x1, 0xc0048beb38)
        /home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/ast/inspector/inspector.go:77 +0xa2
github.com/projectcontour/lint/pkg/analysis/importalias.run(0xc0058d8f70, 0xc0058d8f70, 0x0, 0x0, 0x0)
        /home/ldez/sources/go/src/github.com/projectcontour/lint/pkg/analysis/importalias/analyzer.go:41 +0xcd
golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce(0xc0023c7180)
        /home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:691 +0x85f
sync.(*Once).doSlow(0xc0023c7180, 0xc000176790)
        /home/ldez/.gvm/gos/go1.16/src/sync/once.go:68 +0xec
sync.(*Once).Do(...)
        /home/ldez/.gvm/gos/go1.16/src/sync/once.go:59
golang.org/x/tools/go/analysis/internal/checker.(*action).exec(0xc0023c7180)
        /home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:579 +0x65
golang.org/x/tools/go/analysis/internal/checker.execAll.func1(0xc0023c7180)
        /home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:567 +0x34
created by golang.org/x/tools/go/analysis/internal/checker.execAll
        /home/ldez/sources/go/pkg/mod/golang.org/x/[email protected]/go/analysis/internal/checker/checker.go:573 +0x125

What did you expect to happen:

Don't panic

@ldez ldez added the kind/bug Categorizes issue or PR as related to a bug. label Feb 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

1 participant