Open dkegel-fastly opened 3 years ago
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/goreduce@v0.0.0-20201225105240-9763df993ebd/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/goreduce@v0.0.0-20201225105240-9763df993ebd/rules.go:861 +0xe7
main.(*reducer).removeDecl(0xc0001507e0, 0xc0001410e0, 0xc000f2d500)
/Users/dkegel/go/pkg/mod/mvdan.cc/goreduce@v0.0.0-20201225105240-9763df993ebd/rules.go:494 +0x585
main.(*reducer).afterDelete(0xc0001507e0, 0xc000f2d5e8, 0x1, 0x1)
/Users/dkegel/go/pkg/mod/mvdan.cc/goreduce@v0.0.0-20201225105240-9763df993ebd/rules.go:755 +0x2d0
main.(*reducer).removeStmt(0xc0001507e0, 0xc000113e08)
/Users/dkegel/go/pkg/mod/mvdan.cc/goreduce@v0.0.0-20201225105240-9763df993ebd/rules.go:598 +0x2b7
main.(*reducer).reduceNode(0xc0001507e0, 0x1272320, 0xc000113e08, 0xc000244001)
...
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.
Now, uh, do I use goreduce to find the minimal source that causes the goreduce panic? :-)