Add support for comparing equality on reflective values
This commit is contained in:
parent
2918260c5a
commit
678507bcbe
@ -576,6 +576,16 @@ impl<'a, O: OutputSystem + Send, LS: LocalisationSystem + Sync + Send> Interpret
|
||||
match (lval, rval) {
|
||||
(Value::Bool(lbool), Value::Bool(rbool)) => Ok(Value::Bool(lbool == rbool)),
|
||||
(Value::Int(lint), Value::Int(rint)) => Ok(Value::Bool(lint == rint)),
|
||||
(Value::Reflective(lreflect), Value::Reflective(rreflect)) => {
|
||||
match lreflect.reflect_partial_eq(rreflect.as_ref()) {
|
||||
Some(answer) => Ok(Value::Bool(answer)),
|
||||
None => Err(InterpreterError::TypeError {
|
||||
context: "Equals".to_string(),
|
||||
conflict: format!("can't test reflectives {lreflect:?} and {rreflect:?} for equality: they don't support it!"),
|
||||
location: loc.clone(),
|
||||
})
|
||||
}
|
||||
},
|
||||
(lother, rother) => Err(InterpreterError::TypeError {
|
||||
context: "Equals".to_string(),
|
||||
conflict: format!("can't test {lother:?} and {rother:?} for equality!"),
|
||||
|
Loading…
Reference in New Issue
Block a user