From 1b45066f3918b64f7a174b60ad0f2cd269f599e6 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Tue, 8 Jan 2019 19:26:56 -0600 Subject: [PATCH] BUGFIX: Found a bug in deep equality for lists :-( --- integration_tests/comparisons_test.ucg | 8 ++++++++ integration_tests/functional_processing_test.ucg | 8 ++++++++ src/build/ir.rs | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/integration_tests/comparisons_test.ucg b/integration_tests/comparisons_test.ucg index c047220..08b0469 100644 --- a/integration_tests/comparisons_test.ucg +++ b/integration_tests/comparisons_test.ucg @@ -80,6 +80,14 @@ assert | tpl4 != less; |; +assert | + [[1, 2, [3]], 4] == [[1, 2, [3]], 4]; +|; + +assert | + [[1, 2, [3]], 4] != [[1, 2, [6]], 4]; +|; + // Expression comparisons assert |2 == 1+1;|; assert |(1+1) == 2;|; diff --git a/integration_tests/functional_processing_test.ucg b/integration_tests/functional_processing_test.ucg index a39c7a8..77434a0 100644 --- a/integration_tests/functional_processing_test.ucg +++ b/integration_tests/functional_processing_test.ucg @@ -22,6 +22,14 @@ assert | reduce identity_list_reducer.result [], list1 == list1; |; +let nested_list = { + list = list1, +}; + +assert | + reduce identity_list_reducer.result [], (nested_list.list) == list1; +|; + let list_reducer = macro(acc, item) => { result = acc + item, }; diff --git a/src/build/ir.rs b/src/build/ir.rs index 3557f90..54a3584 100644 --- a/src/build/ir.rs +++ b/src/build/ir.rs @@ -73,7 +73,9 @@ impl Val { Ok(false) } else { for (i, lv) in ldef.iter().enumerate() { - lv.equal(rdef[i].as_ref(), pos.clone())?; + if !lv.equal(rdef[i].as_ref(), pos.clone())? { + return Ok(false); + } } Ok(true) }