mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 08:17:40 +03:00
576f1293fd
By emitting a runtime error rather than panicking when we can't layout a record, we help programs like ``` main = get = \{a} -> a get {b: "hello world"} ``` execute as ``` Mismatch in compiler/unify/src/unify.rs Line 1071 Column 13 Trying to unify two flat types that are incompatible: EmptyRecord ~ { 'a' : Demanded(122), }<130> 🔨 Rebuilding host... ── TYPE MISMATCH ─────────────────────────────────────────────────────────────── The 1st argument to get is not what I expect: 8│ get {b: "hello world"} ^^^^^^^^^^^^^^^^^^ This argument is a record of type: { b : Str } But get needs the 1st argument to be: { a : a }b Tip: Seems like a record field typo. Maybe a should be b? Tip: Can more type annotations be added? Type annotations always help me give more specific messages, and I think they could help a lot in this case ──────────────────────────────────────────────────────────────────────────────── '+fast-variable-shuffle' is not a recognized feature for this target (ignoring feature) '+fast-variable-shuffle' is not a recognized feature for this target (ignoring feature) Done! Application crashed with message Can't create record with improper layout Shutting down ``` rather than the hanging ``` Mismatch in compiler/unify/src/unify.rs Line 1071 Column 13 Trying to unify two flat types that are incompatible: EmptyRecord ~ { 'a' : Demanded(122), }<130> thread '<unnamed>' panicked at 'invalid layout from var: UnresolvedTypeVar(104)', compiler/mono/s rc/layout.rs:1510:52 ``` that was previously produced. Part of #2227 |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |