Closed bbrk24 closed 2 months ago
Adding a void
type annotation to the function or a trailing ;
will omit the implicit return.
f := (a, b): void ->
yield a
loop
yield b
[a, b] = [b, a + b]
f := (a, b) ->
yield a
loop
yield b
[a, b] = [b, a + b]
;
We may be able to omit the return in this simple case but probably not generally.
Does ESLint complain about the inaccessible return
in this case? We could try to mimic their algorithm for conservative unreachability testing, to avoid warnings. But I imagine you were concerned more about efficiency, for which I think Daniel's response is the right one.
When writing an infinite generator, such as the below, Civet emits an unreachable return statement:
While this could be removed, there are some things we have to be careful of:
break
inside the loop, the return statement becomes reachableloop
itself may be omitted -- conditionals may not trigger, andtry
blocks may terminate due to an error.