-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent Handling of ! Operator #7103
Comments
Some notes investigating this bug...this is about as far as my brain can handle for today. The issue looks to be related to interaction between the top level type annotation and having a suffixed statement in that final position as this gets us to this position in In That will immediately unwrap giving us an Err(EUnwrapped::UnwrappedSubExpr {
sub_arg,
sub_pat,
sub_new,
target,
}) With the following values...
We pass these into the AnnotatedBody {
ann_pattern,
ann_type,
lines_between,
body_pattern,
body_expr: apply_try_function(
arena,
body_expr.region,
sub_arg,
sub_pat,
sub_new,
Some((ann_pattern, ann_type)),
target,
),
} Which now causes issues because the ident: if loc_ann_pat.value.equivalent(&loc_pat.value) {
new_ident
} else {
// create another pattern to preserve inconsistency
arena.alloc(next_unique_suffixed_ident())
}, And the "create another pattern to preserve inconsistency" then causes us issues. I'm wondering if this should blow up at this point instead of creating another pattern which seems to be failing silently. |
Thanks for taking a look @lukewilliamboswell. I wish I can contribute here but unfortunately I don't know Rust at all. And I could be totally out of line here but logically what makes sense to me is that it's related to the simple fact that Roc allows you to use ! operator on the last line, even though there is no 2nd task added!?! Wouldn't it be more logically correct to not allow that at all? I guess it's time for me to go learn Rust first because I genuinely want to contribute to Roc in any way shape or form. |
We decided to allow that for consistency but the |
I've encountered an inconsistency in how the Roc language handles the ! operator when used within functions. Specifically, the behavior differs depending on whether the ! operator is used as a standalone statement or as the last line of a function.
The following code works as expected:
However, if I remove the last two lines, it fails:
I am calling the
run
function simply as follows:Note: Removing the annotation solves the problem, and so does removing the ! operator from the last line.
Tested w/ basic-cli (0.15.0).
The text was updated successfully, but these errors were encountered: