Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

panic: could not remove name declaration #28

Open
dkegel-fastly opened this issue Apr 15, 2021 · 2 comments
Open

panic: could not remove name declaration #28

dkegel-fastly opened this issue Apr 15, 2021 · 2 comments

Comments

@dkegel-fastly
Copy link

Now, uh, do I use goreduce to find the minimal source that causes the goreduce panic? :-)

panic: could not remove name declaration

goroutine 1 [running]:
main.(*reducer).removeDecl(0xc00012c7e0, 0xc0000681a0, 0xc001121500)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:509 +0x645
main.(*reducer).afterDelete(0xc00012c7e0, 0xc0011215e8, 0x1, 0x1)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:755 +0x2d0
main.(*reducer).removeStmt(0xc00012c7e0, 0xc00007f058)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:598 +0x2b7
main.(*reducer).reduceNode(0xc00012c7e0, 0x1272320, 0xc00007f058, 0xc000197301)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:78 +0xc9c
main.(*walker).walkSingle(0xc00012c8d8, 0x1272320, 0xc00007f058)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/walk.go:60 +0x5b
main.(*walker).walk(0xc00012c8d8, 0x128c200, 0xc00007f830, 0xc0005b9a40)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/walk.go:27 +0xaa
main.(*reducer).reduceLoop(0xc00012c7e0, 0x0)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/reduce.go:254 +0x185
main.reduce(0x7ffeefbffb9e, 0x1, 0x7ffeefbffb28, 0xf, 0x13228b0, 0xc000010020, 0x7ffeefbffb3d, 0x60, 0x0, 0x0)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/reduce.go:146 +0xa28
main.main()
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/main.go:58 +0x135
@dkegel-fastly
Copy link
Author

dkegel-fastly commented Apr 15, 2021

Happy to rerun with a debugging branch.

Here's the output with -v (it changes a bit on each run):

fooi.go:61: removed const decl (first try)
bar.go:3: removed const decl (first try)
bletch.go:168: removed const decl (first try)
panic: could not remove name declaration

goroutine 1 [running]:
main.(*reducer).removeDecl(0xc00012e7e0, 0xc0003699c0, 0xc00112d500)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:509 +0x645
...

although once there was something worse:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x12564e7]

goroutine 1 [running]:
main.(*reducer).replaceStmts(0xc0001507e0, 0x1326560, 0xc00013f5c0, 0x0, 0x0, 0x0, 0x20)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:861 +0xe7
main.(*reducer).removeDecl(0xc0001507e0, 0xc0001410e0, 0xc000f2d500)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:494 +0x585
main.(*reducer).afterDelete(0xc0001507e0, 0xc000f2d5e8, 0x1, 0x1)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:755 +0x2d0
main.(*reducer).removeStmt(0xc0001507e0, 0xc000113e08)
	/Users/dkegel/go/pkg/mod/mvdan.cc/[email protected]/rules.go:598 +0x2b7
main.(*reducer).reduceNode(0xc0001507e0, 0x1272320, 0xc000113e08, 0xc000244001)
...

@mvdan
Copy link
Owner

mvdan commented Apr 29, 2021

It shouldn't come as a surprise that I don't develop this project actively at the moment :) This sounds like a syntax edge case that we don't handle properly.

Happy to review a patch and test if you'd like to look into it. Assuming that you're using the rewrite/substitution feature, I think https://github.com/rsc/rf is a better design long-term, but it's quite experimental at the moment.

Edit: I got confused with a different project. Ignore that last line. goreduce and rf are entirely different.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants