roc
roc copied to clipboard
Desugar tuples to records
This is part of the SIMD proposal, and comes after https://github.com/rtfeldman/roc/issues/2932 and https://github.com/rtfeldman/roc/issues/2934
Tuples should desugar to numbered record fields; e.g. (a, b) should desugar to { 0: a, 1: b }.
This should presumably be done at the type-checking stage so that we can record that something originated as a tuple, allowing us to pretty-print errors using tuple syntax instead of record syntax even after the desugaring has happened.
Is the desugared version meant to be usable outside of transforming tuples? Meaning, is the following valid Roc?
rec = { a: "hello", 4: 5 }
If the above is valid, we hit a problem destructuring. From the above example
{ 5 } = rec
Here, 5 would be a variable reference & a number literal.
Yeah, the first code snippet should be valid Roc!
{ 5 } = rec should be a new compile error (probably checked during canonicalization) which is that you can't destructure numbered record fields.
Closing as I think this is completed.