Stream: bugs

Topic: ✔ Parse error when function conditionally returns list


view this post on Zulip Ian McLerran (Jan 16 2025 at 18:16):

So I have discovered a bug where a function which conditionally returns a list will produce an unhandled parse error:

── UNHANDLED PARSE ERROR in Utils.roc  ────────────────────

I got stuck while parsing this:
1│  module [if_else_list]
2│
3│  if_else_list : U8 -> List U8
4│  if_else_list |in|
    ^

Here's the internal parse problem:
    UnexpectedTopLevelExpr(@52)
module [if_else_list]

if_else_list : U32 -> List U8
if_else_list |in|
    if in < 1 then
        []
    else
        [1]

same for:

if_else_list |in|
    when in is
        num if num < 1 -> []
        _ -> [1]

view this post on Zulip Sam Mohr (Jan 16 2025 at 18:18):

You're missing an equals sign before the args list

view this post on Zulip Ian McLerran (Jan 16 2025 at 18:19):

Can code gud.

view this post on Zulip Notification Bot (Jan 16 2025 at 18:19):

Ian McLerran has marked this topic as resolved.

view this post on Zulip Kilian Vounckx (Jan 16 2025 at 18:20):

Could be a better error message though

view this post on Zulip Ian McLerran (Jan 16 2025 at 19:00):

True that!


Last updated: Jul 06 2025 at 12:14 UTC