-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
feat: allow ResultTryQuestion suffix in AST #6844
feat: allow ResultTryQuestion suffix in AST #6844
Conversation
What do you think about adding a couple of snapshot tests too? What you have so far looks good to me. |
Great point, working on it rn. |
@lukewilliamboswell added snapshot testing by adding analogous examples in files that previously contained only the task bang suffix, lmk if you"d rather I split out into different files |
@sekerez I"m not Luke Boswell, but I"d vote for splitting out into different files. It makes the testing more single responsibility, and we may have the ? and ! behave differently in the future, though I don"t find it likely. However, I"d understand wanting to keep them in the same file, in that we want any tests updated for ! to also get updated for ?, as their behavior is currently expected to be basically identical. |
Just a heads-up: I"m changing the parsing logic a little bit here: #6851 |
What about I mean: and = \resultA, resultB ->
resultA? # return resultA if it"s Result.err
resultB? # otherwise return resultB |
@kdziamura great point - I feel like it should be forbidden, as if Just to check my understanding, returning a value with edit: I"m a little surprised that code like this compiles:
and behaves identically to
given that in my mind the return type differs, based on the same reasoning for Is my understanding incorrect? Should we as a matter of convention allow returning |
@smores56 that makes sense - I"ll split out into separate files, and changes the original files" name to @kdziamura also rebasing on your changes. |
It will be desugared into
Which makes sense for consistency ( So, we can indeed fully piggyback the |
@@ -550,7 +553,7 @@ pub fn is_expr_suffixed(expr: &Expr) -> bool { | |||
// expression without arguments, `read!` | |||
Expr::Var { .. } => false, | |||
|
|||
Expr::TaskAwaitBang(..) => true, | |||
Expr::TaskAwaitBang(..) | Expr::ResultTryQuestion(..) => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let"s also update is_top_level_suffixed
function in this file. The behaviour should be the same as for TaskAwaitBang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After that, some of snapshots will change. In particular, it will affect the postfix in the statement position
x = B.b? "Foo" | ||
c? x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These statements should be parsed as part of the main
#6844 (comment)
Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked |
@sekerez I realize that I have some spare development capacity, and I see that this PR hasn"t had progress in about a month and a half. Would you mind if I chipped in on getting this out the door? |
I was able to implement this by hijacking the |
Makes progress toward #6828, based on this excellent guide!
No tests required changes, I"ll add new automated tests in the desugar followup unless there are recommendations.