gopherdata / gophernotes

The Go kernel for Jupyter notebooks and nteract.
MIT License
3.82k stars 265 forks source link

No compile error with missing function returns #128

Closed btracey closed 5 years ago

btracey commented 6 years ago

The cell f := func(x []float64) float64 {} does not end with a compile error.

cosmos72 commented 6 years ago

True, gophernotes is more relaxed than compiled Go in this case: it does not check that functions with return values actually end with a "terminating statement" (a return, goto, infinite loop...).

The exact specs of what constitutes a "terminating statement" are a bit complex - see https://golang.org/ref/spec#Function_declarations and https://golang.org/ref/spec#Terminating_statements

If I have time, I will work on this, but since it's in the realm "accept invalid code" I consider it lower priority than bugs where gophernotes rejects valid code.

If you look at it from another angle, one may even argue that it's a gophernotes language extension - although an involuntary one.