segmentio / golines

A golang formatter that fixes long lines
MIT License
903 stars 56 forks source link

panic: interface conversion: interface is nil, not dst.Expr #114

Closed poszu closed 10 months ago

poszu commented 10 months ago

Hi, first of all - thanks for building this tool!

It crashes for me when formatting specific file: https://github.com/spacemeshos/go-spacemesh/blob/adb28491d5576a32767dad72bea131417871a9b2/hare/eligibility/oracle.go.

❯ golines -d hare/eligibility/oracle.go
[2023-10-23 13:23:59] DEBUG Processing file hare/eligibility/oracle.go
[2023-10-23 13:23:59] DEBUG Starting round 0
panic: interface conversion: interface is nil, not dst.Expr

goroutine 1 [running]:
github.com/dave/dst/decorator.(*fileDecorator).decorateNode(0xc000219a58, {0x825db8, 0xc0000a5100}, {0x7ac598, 0xa}, {0x7aa83a, 0x3}, {0x7aab19, 0x4}, {0x825ef8, ...})
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator-node-generated.go:318 +0x23fc
github.com/dave/dst/decorator.(*fileDecorator).decorateNode(0xc000219a58, {0x825ea8, 0xc0001e63f0}, {0x7abeaa, 0x9}, {0x7aa9f5, 0x4}, {0x7aaa35, 0x4}, {0x825db8, ...})
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator-node-generated.go:82 +0x12de5
github.com/dave/dst/decorator.(*fileDecorator).decorateNode(0xc000219a58, {0x8260d8, 0xc0001e6420}, {0x7aba00, 0x8}, {0x7aa9fd, 0x4}, {0x7abeaa, 0x9}, {0x825ea8, ...})
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator-node-generated.go:246 +0x128da
github.com/dave/dst/decorator.(*fileDecorator).decorateNode(0xc000219a58, {0x825d68, 0xc00003cf00}, {0x7aaa15, 0x4}, {0x7aacd8, 0x5}, {0x7aaa0d, 0x4}, {0x8260d8, ...})
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator-node-generated.go:953 +0x5b94
github.com/dave/dst/decorator.(*fileDecorator).decorateNode(0xc000219a58, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x825d68, ...})
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator-node-generated.go:788 +0x109ca
github.com/dave/dst/decorator.(*Decorator).DecorateNode(0xc0000fbf80, {0x825d68?, 0xc00003cf00?})
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator.go:134 +0x165
github.com/dave/dst/decorator.(*Decorator).DecorateFile(0xc0000a4580?, 0x0?)
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator.go:109 +0x1d
github.com/dave/dst/decorator.(*Decorator).ParseFile(0xc0000fbf80, {0x0?, 0xc0001d6800?}, {0x732f40?, 0xc000012378?}, 0x18?)
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator.go:81 +0x5f
github.com/dave/dst/decorator.(*Decorator).Parse(...)
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/decorator.go:67
github.com/dave/dst/decorator.Parse({0x732f40, 0xc000012378})
        /home/bartosz/go/pkg/mod/github.com/dave/dst@v0.26.2/decorator/helpers.go:17 +0x165
main.(*Shortener).Shorten(0xc0000fb730, {0xc0001b4000?, 0x3ec5?, 0x3ec6?})
        /home/bartosz/go/pkg/mod/github.com/segmentio/golines@v0.9.0/shortener.go:134 +0x35b
main.processFile(0x7ffc0ec5307a?, {0x7ffc0ec5307a, 0x1a})
        /home/bartosz/go/pkg/mod/github.com/segmentio/golines@v0.9.0/main.go:219 +0x188
main.run()
        /home/bartosz/go/pkg/mod/github.com/segmentio/golines@v0.9.0/main.go:188 +0x2a5
main.main()
        /home/bartosz/go/pkg/mod/github.com/segmentio/golines@v0.9.0/main.go:109 +0x145
poszu commented 10 months ago

Sorry, I just noticed that v0.9.0 is not the latest version. I blindly copied installation instructions from readme that point to v0.9.0.

The crash doesn't reproduce with v0.11.0.