Stream: compiler development

Topic: allowing bare `return`/`try` statements


view this post on Zulip Sam Mohr (Nov 08 2024 at 08:45):

Currently a function that has a bare try validatePurely data as a statement in its body gets a compiler error because it "doesn't introduce any new variables". Even though the statement is pure, it conditionally early returns, so it does affect the outcome of the function.

I think we should check if statements contain early returns, and if they do we should allow them. Does anyone disagree?

view this post on Zulip Agus Zubiaga (Nov 08 2024 at 10:56):

I agree, but I think that should only be allowed if the Ok branch is {}

view this post on Zulip Sam Mohr (Nov 08 2024 at 11:00):

Sure

view this post on Zulip Brendan Hansknecht (Nov 08 2024 at 15:51):

Yeah. Should only be for Ok {}. The rest should require _ = try ...


Last updated: Jul 06 2025 at 12:14 UTC