roc
roc copied to clipboard
```roc repl``` crashes when result incorrectly comparing Result
Trying to compare a Result incorrectly crashes using roc repl. The return value is Ok 12 so it should give an error instead.
» Dict.get (Dict.insert (Dict.empty) "Apples" 12) "Apples"
Ok 12 : Result (Num *) [KeyNotFound]*
» Dict.get (Dict.insert (Dict.empty) "Apples" 12) "Apples" == Ok 12
Bool.true : Bool
» Dict.get (Dict.insert (Dict.empty) "Apples" 12) "Apples" == 12
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Erroneous', crates/compiler/mono/src/ir.rs:9704:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The REPL no longer panics with the third example:
» Dict.get (Dict.insert (Dict.empty {}) "Apples" 12) "Apples" == 12
This Roc code crashed with: "Hit an erroneous type when creating a layout for `Dict.get`"
── TYPE MISMATCH ───────────────────────────────────────────────────────────────
This 2nd argument to == has an unexpected type:
4│ Dict.get (Dict.insert (Dict.empty {}) "Apples" 12) "Apples" == 12
^^
The argument is a number of type:
Num *
But == needs its 2nd argument to be:
[
Err [KeyNotFound],
Ok (Num *),
]
However, the output is now incorrect for the other examples:
» Dict.get (Dict.insert (Dict.empty {}) "Apples" 12) "Apples"
Err KeyNotFound : Result (Num *) [KeyNotFound]
Dict.get (Dict.insert (Dict.empty {}) "Apples" 12) "Apples" == Ok 12
Bool.false : Bool