links
links copied to clipboard
Disallow empty blocks
Following #900 we should disallow empty block expressions. Currently the following expression
fun() { }
desugars into
fun() { () }
This change would be easy enough to make as part of #900, but we should probably discuss its ramifications first.
I just experimented with this by disabling the /* empty */ line in the grammar (in #900). Seventeen tests fail to parse as a result. Most cases are variations on fun foo() {} where we want to define a function that returns unit. Clearly, these are all fixable by adding an explicit (), but I'm not convinced that requiring writing fun foo() {()} is better. Granted, it would certainly be more uniform.