From 599ed314147b44455894497a7ee47f7d764f2791 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 15 Jan 2019 18:49:15 -0600 Subject: [PATCH] FIX: NULL equality should be useable with any type. --- integration_tests/comparisons_test.ucg | 10 ++++++++++ src/build/ir.rs | 3 +++ 2 files changed, 13 insertions(+) diff --git a/integration_tests/comparisons_test.ucg b/integration_tests/comparisons_test.ucg index 1839d5f..9ded6c3 100644 --- a/integration_tests/comparisons_test.ucg +++ b/integration_tests/comparisons_test.ucg @@ -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", }; \ No newline at end of file diff --git a/src/build/ir.rs b/src/build/ir.rs index 65b9174..b7c3c43 100644 --- a/src/build/ir.rs +++ b/src/build/ir.rs @@ -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,