Stream: beginners

Topic: Missing closing parenthesis


view this post on Zulip Ilya Shmygol (Apr 22 2025 at 11:16):

Hi. Really beginner question. Why am I getting error here?

walk_try_with_index :
    List elem,
    state,
    (state, elem, U64 -> Result state err)
    -> Result state err
walk_try_with_index = |list, state, f|
    list
    |> List.walk_try(
        {index: 0, state},
        |compound_state, elem|
            Ok(
                {
                    index: compound_state.index + 1,
                    state: f(compound_state.state, elem, compound_state.index)!,
                }
            )
    )
    |> Result.map_ok(.state)

Error:

UNFINISHED PARENTHESES

I am partway through parsing a record pattern, but I got
stuck here:

10│      |> List.walk_try(
11│          {index: 0, state},
12│          |compound_state, elem|
             ^

I was expecting to see a closing parenthesis next, so try
adding a ) and see if that helps?

I really can not understand what is wrong here. Is there a chance the compiler messes with me?

view this post on Zulip Anton (Apr 22 2025 at 11:51):

Hi @Ilya Shmygol,
The ! needs to be a ?

state: f(compound_state.state, elem, compound_state.index)!

So:

state: f(compound_state.state, elem, compound_state.index)?

view this post on Zulip Anton (Apr 22 2025 at 11:51):

I think we want to deprecate that old use of !, I'll check on that

view this post on Zulip Ilya Shmygol (Apr 22 2025 at 11:53):

:facepalm:

view this post on Zulip Ilya Shmygol (Apr 22 2025 at 11:54):

Thanks @Anton, it was it.

view this post on Zulip Anton (Apr 22 2025 at 11:55):

Yeah, the error message was really distracting here


Last updated: Jul 06 2025 at 12:14 UTC