Skip to content
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

Ignore final try suffix for annotated top-level defs #7128

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

lukewilliamboswell
Copy link
Collaborator

Fixes #7103

Also tested using the following program cargo run --main.roc

app [main] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.15.0/SlwdbJ-3GR7uBWQo6zlmYWNYOxnvo8r6YABXD-45UOw.tar.br",
}

import pf.Stdout
import pf.Stdin

run : Task {} _
run =
    Stdout.line! "Say something:"
    input = Stdin.line!
    Stdout.line! "You said: $(input)"

main = run

@lukewilliamboswell
Copy link
Collaborator Author

Also Fixes #7127

// When the last expression is suffixed, it will try to unwrap the def, but because we
// have an annotated def we can simply ignore the try and return it as is without
// creating an intermediate identifier
Err(EUnwrapped::UnwrappedDefExpr { loc_expr, .. }) => desugar_value_def_suffixed(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of using a syntax error as special state to decide when to successfully continue, but:

  1. We probably do this elsewhere
  2. This code is going away with purity inference and the new try keyword

So it doesn't matter enough to be worth making much cleaner.

@lukewilliamboswell lukewilliamboswell merged commit 2c62f77 into main Oct 2, 2024
18 checks passed
@lukewilliamboswell lukewilliamboswell deleted the fix-7103 branch October 2, 2024 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Handling of ! Operator
2 participants