Stream: beginners

Topic: Can't parse record?


view this post on Zulip itmuckel (Mar 27 2023 at 20:04):

The parser fails at the first brace of the record in the then branch:

        s = List.walk chunks {lastBiggest : 0, current: 0} \state, elem ->
                num = Str.toNat elem
                if (Result.isOk num) then
                    { state & current: (state.current + (Result.withDefault num crash)) }
                else
                    { lastBiggest: state.current, current: 0 }

Is there a syntax error?

view this post on Zulip itmuckel (Mar 27 2023 at 20:05):

Oh, okay, when I replace the crash by a number it works. Not sure if there should be an error here :thinking:

view this post on Zulip Folkert de Vries (Mar 27 2023 at 21:09):

crash is a statement, not an expression

view this post on Zulip Folkert de Vries (Mar 27 2023 at 21:09):

but if the error did not make that clear, that is a bug

view this post on Zulip Richard Feldman (Mar 28 2023 at 02:53):

I think at some point we talked about giving explicit warnings about crash being used in an argument position :thinking:

view this post on Zulip Richard Feldman (Mar 28 2023 at 02:53):

because it can't work, but it looks like it might!


Last updated: Jul 06 2025 at 12:14 UTC