gopherdata/gophernotes

Invalid "for" loop causes panic

robusto opened this issue · 2 comments

Executing a cell with an invalid "for" loop causes a panic and kills the Jupyter kernel:

  • Example 1 (invalid operator): "for i := 0; i < 10; ++i { ... }

Correct build error: syntax error: unexpected ++, expecting expression

  • Example 2 (forgotten semicolon): "for i := xi < 5; i++ { ... }

Correct build error: syntax error: unexpected {, expecting semicolon or newline

Output in shell running "jupyter notebook":

func_proxy.go:4:4: expected declaration, found 'for'
panic: exit status 2

goroutine 1 [running]:
panic(0x42d8640, 0xc4202cc0a0)
        /usr/local/Cellar/go/1.7/libexec/src/runtime/panic.go:500 +0x1a1
github.com/gopherds/gophernotes/internal/repl.(*Session).Eval(0xc4200b2370, 0xc42024ef80, 0x3c, 0xc4202e3488, 0xc420013580, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        <$GOPATH>/src/github.com/gopherds/gophernotes/internal/repl/repl.go:374 +0x19a3
main.HandleExecuteRequest(0xc42046f6c0, 0x20, 0xc4200134a8, 0x8, 0xc42046f700, 0x20, 0xc4200134d0, 0xf, 0x0, 0x0, ...)
        <$GOPATH>/src/github.com/gopherds/gophernotes/execution.go:60 +0x2f3
main.HandleShellMsg(0xc42046f6c0, 0x20, 0xc4200134a8, 0x8, 0xc42046f700, 0x20, 0xc4200134d0, 0xf, 0x0, 0x0, ...)
        <$GOPATH>/src/github.com/gopherds/gophernotes/gophernotes.go:108 +0x2c7
main.RunKernel(0x7fff5fbff6ae, 0x59, 0x4493360, 0xc4200122a8)
        <$GOPATH>/src/github.com/gopherds/gophernotes/gophernotes.go:194 +0x842
main.main()
        <$GOPATH>/src/github.com/gopherds/gophernotes/main.go:25 +0xc6

Running on OS X 10.11.6, Golang 1.7

Thanks @robusto. We should definitely change this and provide a more instructive error.

@robusto I think this is now fixed in the v1 RC. Closing for now. Please reach out with any further issues, and thanks!