Closed ghost closed 4 years ago
'If true: quit' is good enough
Yeah, however, if true
is an idiom that has to be learned. I'm torn.
+1 This would make it easier and more beginner friendly, for example when inserting an early return statement for debugging purpose.
when off:
?.
This:
proc a() =
quit(0)
block: echo "hi"
a()
currently compiles without error, which is a bit illogical, but if we were to fix it so that it errors it would be a breaking change. Making it a warning and fixing it would be a solution without a breaking change (I did that in https://github.com/nim-lang/Nim/pull/14816) :D
Currently code like
would not compile with the error
unreachable statement after 'return' statement or '{.noReturn.}' proc
. I propose to make it a warning instead, which will still be quite visible to the developer but it'll allow for faster prototyping in some cases.Please comment, I might not know some cases where this can lead to new bugs or unintended behaviour.
Also see nim-lang/nim#14190 because it's a bit similar in a sense that this PR made it possible to have unreachable
else
branch in a case statement.