FIX: NULL equality should be useable with any type.

This commit is contained in:
Jeremy Wall 2019-01-15 18:49:15 -06:00
parent 98323eabbd
commit 599ed31414
2 changed files with 13 additions and 0 deletions

View File

@ -168,4 +168,14 @@ assert {
assert {
ok = "foo" !~ "bar",
desc = "\"foo\" !~ \"bar\"",
};
assert {
ok = NULL != 1,
desc = "Integers are comparable to null",
};
assert {
ok = NULL != "string",
desc = "Strings are comparable to null",
};

View File

@ -109,6 +109,9 @@ impl Val {
error::ErrorType::TypeFail,
pos,
)),
// EMPTY is always comparable for equality.
(&Val::Empty, _) => Ok(false),
(_, &Val::Empty) => Ok(false),
(me, tgt) => Err(error::BuildError::new(
format!("Types differ for {}, {}", me, tgt),
error::ErrorType::TypeFail,