-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
Hi!
I run into an issue where decorator.Parse may panic on invalid *.go file content.
Example:
If I have a invalid.go file content begin with wrong declaration of package like:
pkg mainor just an empty go file may cause panic at:
panic({0x8e77e0?, 0xd5df80?})
/usr/local/go/src/runtime/panic.go:920 +0x270
go/token.(*File).Base(...)
/usr/local/go/src/go/token/position.go:114
github.com/dave/dst/decorator.(*fileDecorator).fragment.func1(0xc0001c8780)
/home/sasuke/go/pkg/mod/github.com/dave/dst@v0.27.3/decorator/decorator-fragment.go:128 +0x46d
github.com/dave/dst/decorator.(*fileDecorator).fragment(0xc0001353f8, {0xa50a20?, 0xc0001c8780?})
/home/sasuke/go/pkg/mod/github.com/dave/dst@v0.27.3/decorator/decorator-fragment.go:170 +0x99
github.com/dave/dst/decorator.(*Decorator).DecorateNode(0xc0001a7e30, {0xa50a20?, 0xc0001c8780?})
/home/sasuke/go/pkg/mod/github.com/dave/dst@v0.27.3/decorator/decorator.go:131 +0x11c
github.com/dave/dst/decorator.(*Decorator).DecorateFile(0xc00049d540?, 0x0?)
/home/sasuke/go/pkg/mod/github.com/dave/dst@v0.27.3/decorator/decorator.go:109 +0x1d
github.com/dave/dst/decorator.(*Decorator).ParseFile(0xc0001a7e30, {0x0?, 0xc00002c603?}, {0x9695e0?, 0xc000056708?}, 0x0?)
/home/sasuke/go/pkg/mod/github.com/dave/dst@v0.27.3/decorator/decorator.go:81 +0x5f
github.com/dave/dst/decorator.(*Decorator).Parse(...)
/home/sasuke/go/pkg/mod/github.com/dave/dst@v0.27.3/decorator/decorator.go:67
github.com/dave/dst/decorator.Parse({0x9695e0, 0xc000056708})
/home/sasuke/go/pkg/mod/github.com/dave/dst@v0.27.3/decorator/helpers.go:17 +0x165
// github.com/dave/dst@v0.27.3/decorator/decorator-fragment.go:128
max := tokenf.Base() + tokenf.Size()Metadata
Metadata
Assignees
Labels
No labels