mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Implement loose comparison against undefined and null
This commit is contained in:
@@ -130,8 +130,10 @@ pub fn op_exp(left: Vallish, right: Vallish) -> Result<Val, Val> {
|
||||
|
||||
pub fn op_eq(left: Vallish, right: Vallish) -> Result<Val, Val> {
|
||||
Ok(Val::Bool(match (left.get_ref(), right.get_ref()) {
|
||||
(Val::Undefined, Val::Undefined) => true,
|
||||
(Val::Null, Val::Null) => true,
|
||||
(left_ref, Val::Undefined | Val::Null) => match left_ref {
|
||||
Val::Undefined | Val::Null => true,
|
||||
_ => false,
|
||||
},
|
||||
(Val::Bool(left_bool), Val::Bool(right_bool)) => left_bool == right_bool,
|
||||
(Val::Number(left_number), Val::Number(right_number)) => left_number == right_number,
|
||||
(Val::String(left_string), Val::String(right_string)) => left_string == right_string,
|
||||
|
||||
Reference in New Issue
Block a user