Stream: compiler development

Topic: Merging non-equivalent annotations + bodies?


view this post on Zulip Joshua Warner (Dec 03 2024 at 00:45):

Now that there's logic in place to merge 'equivalent' annotations + bodies (i.e. where the patterns are equivalent), is there any reason we still want to merge neighboring annotations+bodies when there's no whitespace, even when they're clearly different?

For example, should we merge these?

S i:l
i=l

view this post on Zulip Joshua Warner (Dec 03 2024 at 01:02):

(if you can't tell, this is an example derived from fuzzing :stuck_out_tongue_wink: )

view this post on Zulip Eli Dowling (Dec 03 2024 at 01:39):

I have no idea what I'm looking at, but I'd like to understand, could you give a link to what this merging business is? And also what the output of merging that example would be?

view this post on Zulip Joshua Warner (Dec 03 2024 at 01:58):

In terms of the parser code, I'm basically asking if I can remove the spaces_middle.len() <= 1 || part of this line: https://github.com/roc-lang/roc/blob/main/crates/compiler/parse/src/expr.rs#L3254

view this post on Zulip Joshua Warner (Dec 03 2024 at 01:59):

Here's a more realistic example of where we definitely do want things to be merged:

UserId x : [ UserId I64 ]
UserId x = UserId 42

view this post on Zulip Joshua Warner (Dec 03 2024 at 02:00):

The merging is changing that from being two separate/unrelated "Annotation" + "Body" defs, to a single "AnnotatedBody" def


Last updated: Jul 06 2025 at 12:14 UTC