mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-10 23:28:01 +00:00
Add derive-key implementation for IsEq
This commit is contained in:
parent
16d12a51c2
commit
4c30e4c4bb
3 changed files with 13 additions and 0 deletions
|
@ -76,6 +76,7 @@ pub enum DeriveBuiltin {
|
|||
ToEncoder,
|
||||
Decoder,
|
||||
Hash,
|
||||
IsEq,
|
||||
}
|
||||
|
||||
impl TryFrom<Symbol> for DeriveBuiltin {
|
||||
|
@ -86,6 +87,7 @@ impl TryFrom<Symbol> for DeriveBuiltin {
|
|||
Symbol::ENCODE_TO_ENCODER => Ok(DeriveBuiltin::ToEncoder),
|
||||
Symbol::DECODE_DECODER => Ok(DeriveBuiltin::Decoder),
|
||||
Symbol::HASH_HASH => Ok(DeriveBuiltin::Hash),
|
||||
Symbol::EQ_IS_EQ => Ok(DeriveBuiltin::IsEq),
|
||||
_ => Err(value),
|
||||
}
|
||||
}
|
||||
|
@ -112,6 +114,11 @@ impl Derived {
|
|||
}
|
||||
FlatHash::Key(repr) => Ok(Derived::Key(DeriveKey::Hash(repr))),
|
||||
},
|
||||
DeriveBuiltin::IsEq => {
|
||||
// If obligation checking passes, we always lower derived implementations of `isEq`
|
||||
// to the `Eq` low-level, to be fulfilled by the backends.
|
||||
Ok(Derived::SingleLambdaSetImmediate(Symbol::BOOL_EQ))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue