Allow terminal return as result of block expression #17813
som-snytt
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One solution to organizing local functions is to allow a terminal return expression in a prefix of statements in a block where the suffix are constrained (perhaps to be defs only, perhaps the next expression must be the inferred unit); then the returned expression is allowed to guide inference of the result type of the enclosing method.
The motivation is to make the result (here, in the return expression) easier to locate than if it were at the bottom of the block.
Another proposal to distinguish local defs from other statements is lampepfl/dotty-feature-requests#231
Beta Was this translation helpful? Give feedback.
All reactions