mage
mage copied to clipboard
panic with latest commit (c807db8c20a2344bac98cf21e08af7b374d63f86)
Error message is not very helpful, but I'm getting this with the most recent magefile.
panic: interface conversion: ast.Expr is *ast.MapType, not *ast.SelectorExpr
goroutine 1 [running]:
github.com/magefile/mage/parse.Package(0x6bc404, 0x1, 0xc420116330, 0x1, 0x1, 0x1, 0x0, 0x8700000000000000)
$GOPATH/src/github.com/magefile/mage/parse/parse.go:110 +0xa4b
github.com/magefile/mage/mage.Invoke(0x6bc404, 0x1, 0x0, 0x0, 0x0, 0x0, 0x6f06c0, 0xc42008e008, 0x6f06c0, 0xc42008e010, ...)
$GOPATH/src/github.com/magefile/mage/mage/main.go:266 +0x3d0
github.com/magefile/mage/mage.ParseAndRun(0x6bc404, 0x1, 0x6f06c0, 0xc42008e008, 0x6f06c0, 0xc42008e010, 0x6f0680, 0xc42008e000, 0xc420080170, 0x0, ...)
$GOPATH/src/github.com/magefile/mage/mage/main.go:140 +0x5f6
github.com/magefile/mage/mage.Main(0xc42007e058)
$GOPATH/src/github.com/magefile/mage/mage/main.go:74 +0xc1
main.main()
$GOPATH/src/github.com/magefile/mage/main.go:10 +0x22
Running magefile in the debugger, the panic occurs here:
typeloop:
for _, t := range p.Types {
for _, s := range t.Decl.Specs {
if id, ok := s.(*ast.TypeSpec); ok {
if id.Type.(*ast.SelectorExpr).X.(*ast.Ident).Name != "mg" || id.Type.(*ast.SelectorExpr).Sel.Name != "Namespace" {
continue typeloop
}
break
}
}
specifically id.Type.(*ast.SelectorExpr) is indeed a Map and not a SelectExpr. The offending code in my Magefile is:
type Env = map[string]string
oops, you know, I was looking at that code and thinking it shouldn't use a type conversion without checking first. I'll fix it. Thanks!