Stream: contributing

Topic: Combining ? and ! in syntax parsing


view this post on Zulip Sam Mohr (Aug 14 2024 at 20:33):

I was looking at the first ResultTryQuestion PR and realized I kept worrying about how we would ensure that ! and ? are kept in sync in their behavior.

Would anyone be opposed to me making a new PR that makes a combined AST node TrySuffix that has an enum TryTarget { Task, Result } field? This is strong coupling of the two suffix operators on purpose, so it seems better than hoping they don't come out of sync.

view this post on Zulip Richard Feldman (Aug 14 2024 at 20:39):

makes sense to me! :thumbs_up:

view this post on Zulip Sam Mohr (Aug 15 2024 at 06:10):

By the way, @Kiryl Dziamura there's a bug in the current ! -> Task.await code:

❯ roc repl

  The rockin' roc repl
────────────────────────

Enter an expression, or :help, or :q to quit.

» x = {
…     y: 123,
…     z: \a ->
…         b = fix! a
…         Task.ok (b * 2)
… }
An internal compiler expectation was broken.
This is definitely a compiler bug.
Please file an issue here: <https://github.com/roc-lang/roc/issues/new/choose>
a Expr::TaskAwaitBang expression was not completely removed in desugar_value_def_suffixed
Location: crates/compiler/can/src/expr.rs:1130:41

view this post on Zulip Sam Mohr (Aug 15 2024 at 06:11):

I'll try to fix it in my PR, but I'll probably defer this to another PR to avoid making my PR much larger

view this post on Zulip Sam Mohr (Aug 15 2024 at 06:36):

https://github.com/roc-lang/roc/issues/7001


Last updated: Jul 06 2025 at 12:14 UTC