Skip to content
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

cmd/shfmt: fix panic on Stmts without Command in -exp.tojson #133

Merged
merged 1 commit into from
Jul 18, 2017

Conversation

ebfe
Copy link
Contributor

@ebfe ebfe commented Jul 18, 2017

Don't recurse into nil interfaces.

$ echo "FOO=a" | shfmt -exp.tojson

panic: reflect: call of reflect.Value.Interface on zero Value

goroutine 1 [running]:
reflect.valueInterface(0x0, ext:0x0, 0x0, 0x1, 0xc4200451d8, 0x40e142)
	/usr/lib/go/src/reflect/value.go:930 +0x1fa
reflect.Value.Interface(0x0, ext:0x0, 0x0, 0xc420092500, 0x280)
	/usr/lib/go/src/reflect/value.go:925 +0x44
main.recurse(0x0, ext:0x0, 0x0, 0x0, 0x0, 0x0, 0x7faf80805960)
	[...]/go/src/github.com/mvdan/sh/cmd/shfmt/json.go:75 +0x485
[..]

@mvdan
Copy link
Owner

mvdan commented Jul 18, 2017

This needs better tests :)

@mvdan mvdan merged commit ea37001 into mvdan:master Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants