-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panic when incorrectly formatted code #52
Comments
It's been a while since I created the However, I'm pretty sure you'd never want to feed any less than an entire valid go file into |
I hit this as well when using ParseFile.
The contents of the file being parsed.
This ends up causing a panic here dst/decorator/decorator-fragment.go Line 128 in 5fa8d6e
Because tokenf is nil.
Its nil because https://github.com/golang/go/blob/10da3b64af1aebfd146fa3b7ecf765ee1b0f0d7d/src/go/ast/ast.go#L1054 But In my case its expected that files maybe missing the package statement; I was hoping to use the dst package to fix that. But it looks like the dst package will panic in that case. Not expecting a fix since it looks like the package isn't being actively developed. Just intended as an FYI for anyone else hitting this issue. I'll probably work around it by ensuring there is a package statement in all my code. |
Hello,
This might be a real edge case, but just wanting to share.
When for example, missing a
package main
you will get a panic:panic: runtime error: invalid memory address or nil pointer dereference
I think earlier versions did not fail this test, and feel like it should gracefully return an error.
The text was updated successfully, but these errors were encountered: