Stream: beginners

Topic: Multiline record overriding


view this post on Zulip jan kili (Feb 20 2022 at 05:24):

Can records that use & be multiline? I have a record with lots of fields (and a lot of reused defaults), but I can't seem to multiline it without crashing the compiler.
Example from the tutorial: fromOriginal = { original & birds: 4, iguanas: 3 }
Style 1:

fromOriginal =
    {
        original &
        birds: 4,
        iguanas: 3,
    }

Style 2:

fromOriginal =
    {
        original
        &
        birds: 4,
        iguanas: 3,
    }

view this post on Zulip jan kili (Feb 20 2022 at 05:26):

Crash:

» x = { a: 1 }
… {
…     x &
…     a: 2
… }
thread '<unnamed>' panicked at 'A SpaceBefore did not get removed during operator desugaring somehow: SpaceBefore(
    Var {
        module_name: "",
        ident: "x",
    },
    [
        Newline,
    ],
)', compiler/can/src/expr.rs:836:13
stack backtrace:
   0:        0x10c83e08f - <unknown>
   1:        0x10be3f73b - <unknown>
   2:        0x10c8310ca - <unknown>
   3:        0x10c834925 - <unknown>
   4:        0x10c8350e8 - <unknown>
   5:        0x10c83e91a - <unknown>
   6:        0x10c83e1b7 - <unknown>
   7:        0x10c8349f0 - <unknown>
   8:        0x10e1e8b4f - <unknown>
   9:        0x10c1c16df - <unknown>
  10:        0x10c1b119f - <unknown>
  11:        0x10c1b835f - <unknown>
  12:        0x10c19e494 - <unknown>
  13:        0x10c6445dd - <unknown>
  14:        0x10c664d82 - <unknown>
  15:        0x10c6249cb - <unknown>
  16:        0x10c623913 - <unknown>
  17:        0x10c624871 - <unknown>
  18:        0x10c83efa9 - <unknown>
  19:     0x7ff81cc774f4 - __pthread_start

view this post on Zulip jan kili (Feb 20 2022 at 05:28):

The same crash happens for

{
     x & a: 2
}

view this post on Zulip jan kili (Feb 20 2022 at 05:37):

This seems like a bug - I'll just report an issue :)

view this post on Zulip jan kili (Feb 20 2022 at 05:55):

https://github.com/rtfeldman/roc/issues/2534


Last updated: Jul 06 2025 at 12:14 UTC