ondrajz/go-callvis

Getting undeclared name when program builds perfectly

cscetbon opened this issue · 3 comments

Can someone help on that ? it doesn't make much sense to me

$ go-callvis ./prog/cmd/alpha/run.go
/src/git/prog/prog/cmd/alpha/run.go:499:31: undeclared name: queryHandler
/src/git/prog/prog/cmd/alpha/run.go:500:32: undeclared name: queryHandler
/src/git/prog/prog/cmd/alpha/run.go:501:32: undeclared name: mutationHandler
/src/git/prog/prog/cmd/alpha/run.go:502:33: undeclared name: mutationHandler
/src/git/prog/prog/cmd/alpha/run.go:503:32: undeclared name: commitHandler
/src/git/prog/prog/cmd/alpha/run.go:504:31: undeclared name: alterHandler
/src/git/prog/prog/cmd/alpha/run.go:548:35: undeclared name: graphqlProbeHandler
/src/git/prog/prog/cmd/alpha/run.go:558:3: undeclared name: allowedMethodsHandler
/src/git/prog/prog/cmd/alpha/run.go:558:25: undeclared name: allowedMethods
/src/git/prog/prog/cmd/alpha/run.go:562:6: undeclared name: adminAuthHandler
/src/git/prog/prog/cmd/alpha/run.go:564:28: undeclared name: getAdminMux
/src/git/prog/prog/cmd/alpha/run.go:570:39: undeclared name: homeHandler
/src/git/prog/prog/cmd/alpha/run.go:571:50: undeclared name: keywordHandler
2022/12/08 09:15:20 packages contain errors

They are in the same package so not sure what's going on. I also get

no concrete method: func (*sync/atomic.Pointer[go/token.File]).CompareAndSwap(old *go/token.File, new *go/token.File) (swapped bool)

goroutine 9005 [running]:
golang.org/x/tools/go/ssa.(*Program).declaredFunc(0x1402d1a8140, 0x14032dbc120)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:124 +0x108
golang.org/x/tools/go/ssa.(*Program).addMethod(0x100b83df8?, 0x14027533730, 0x14032d89bd0)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:86 +0x148
golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83df8?, 0x14027533720?}, 0x0)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:173 +0x668
golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83dd0?, 0x14004061a40?}, 0x0)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:215 +0x4e4
golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83e70?, 0x1400f86cc30?}, 0x1)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:228 +0x544
golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83dd0?, 0x140040619d0?}, 0x0)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:221 +0x500
golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83df8?, 0x14024eec5d0?}, 0x0)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:193 +0x40c
golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83e98?, 0x14024ea3b18?}, 0x0)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:233 +0x5fc
golang.org/x/tools/go/ssa.(*Program).needMethods(0x1402d1a8140, {0x100b83e20?, 0x1402521b000?}, 0x0)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:209 +0x28c
golang.org/x/tools/go/ssa.(*Program).needMethodsOf(0x1402d1a8140?, {0x100b83e20?, 0x1402521b000?})
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/methods.go:145 +0xac
golang.org/x/tools/go/ssa.(*Package).build(0x1402f38ee40)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2275 +0xd0
sync.(*Once).doSlow(0x4d?, 0x1401d336dc0?)
	/opt/homebrew/Cellar/go/1.19.3/libexec/src/sync/once.go:74 +0x104
sync.(*Once).Do(...)
	/opt/homebrew/Cellar/go/1.19.3/libexec/src/sync/once.go:65
golang.org/x/tools/go/ssa.(*Package).Build(...)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2263
golang.org/x/tools/go/ssa.(*Program).Build.func1(0x2f22203a22726944?)
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2247 +0x54
created by golang.org/x/tools/go/ssa.(*Program).Build
	/go/pkg/mod/golang.org/x/tools@v0.0.0-20200305224536-de023d59a5d1/go/ssa/builder.go:2246 +0x180

Running it on go-callvis repo doesn't even work :/

$ go-callvis -tags oss -nostd -nointer -limit github.com/ofabry/go-callvis ./main.go
/src/git/go-callvis/main.go:48:38: undeclared name: CallGraphTypePointer
/src/git/go-callvis/main.go:49:3: undeclared name: CallGraphTypeStatic
/src/git/go-callvis/main.go:49:24: undeclared name: CallGraphTypeCha
/src/git/go-callvis/main.go:49:42: undeclared name: CallGraphTypeRta
/src/git/go-callvis/main.go:49:60: undeclared name: CallGraphTypePointer
/src/git/go-callvis/main.go:58:16: undeclared name: minlen
/src/git/go-callvis/main.go:59:19: undeclared name: nodesep
/src/git/go-callvis/main.go:60:18: undeclared name: nodeshape
/src/git/go-callvis/main.go:61:18: undeclared name: nodestyle
/src/git/go-callvis/main.go:62:18: undeclared name: rankdir
/src/git/go-callvis/main.go:95:2: undeclared name: Analysis
/src/git/go-callvis/main.go:97:10: undeclared name: Analysis
/src/git/go-callvis/main.go:101:17: undeclared name: Analysis
/src/git/go-callvis/main.go:115:11: undeclared name: dotToImage
/src/git/go-callvis/main.go:126:27: undeclared name: Version
/src/git/go-callvis/main.go:144:17: undeclared name: analysis
/src/git/go-callvis/main.go:144:2: undeclared name: Analysis
/src/git/go-callvis/main.go:145:12: undeclared name: Analysis
/src/git/go-callvis/main.go:145:32: undeclared name: CallGraphType
/src/git/go-callvis/main.go:149:23: undeclared name: handler
2022/12/08 18:54:33 packages contain errors

$ go version
go version go1.19.4 darwin/arm64

I met with the same error.

no concrete method: func (*sync/atomic.Pointer[go/token.File]).CompareAndSwap(old *go/token.File, new *go/token.File) (swapped bool)

Hi, I met the same error when using Go 1.20+ then I change to Go 1.19.7, now it works.