Stream: compiler development

Topic: ✔ whitespace sensitivity - match expressions


view this post on Zulip Luke Boswell (Jul 01 2025 at 04:16):

I was getting confused about some parsing errors while working on match expressions. Claude thinks this is the issue.

Looking at these two snapshots, the key difference is indentation:

basic_tag_union.md (works correctly):

match color {
    Red => 1
    Blue => 2
    Green => 3
}

boolean_patterns.md (fails to parse):

match isReady {
    True => "ready to go!"
    False => "not ready yet"
}

The working version uses tabs for indentation, while the broken version uses 4 spaces. You can see this in the token positions:

view this post on Zulip Luke Boswell (Jul 01 2025 at 04:18):

I'm going to investigate a bit further and try and fix. @Anthony Bullard FYI

view this post on Zulip Luke Boswell (Jul 01 2025 at 04:24):

Ignore the above... on deeper inspection I can see the issue is with parsing string literals instead

view this post on Zulip Luke Boswell (Jul 01 2025 at 04:29):

We don't expect any comma's between match branches right? ... I've modified the parser to use newlines and it seems to be happy now.

view this post on Zulip Notification Bot (Jul 01 2025 at 05:44):

Luke Boswell has marked this topic as resolved.

view this post on Zulip Anton (Jul 01 2025 at 09:58):

Luke Boswell said:

We don't expect any comma's between match branches right? ... I've modified the parser to use newlines and it seems to be happy now.

Hmm, I seem to remember something about that, I think it was in a conversation with @Anthony Bullard

view this post on Zulip Anthony Bullard (Jul 02 2025 at 22:46):

i do too, but can't remember where it was or what the outcome was

view this post on Zulip Richard Feldman (Jul 02 2025 at 23:27):

I think ideally we don't need them


Last updated: Jul 06 2025 at 12:14 UTC