diff options
-rw-r--r-- | 057immutable.cc | 17 | ||||
-rw-r--r-- | 064list.mu | 9 |
2 files changed, 20 insertions, 6 deletions
diff --git a/057immutable.cc b/057immutable.cc index 4dc7a2aa..6a5d97d6 100644 --- a/057immutable.cc +++ b/057immutable.cc @@ -563,8 +563,21 @@ $error: 0 if (has_property(current_ingredient, "contained-in")) { const string_tree* tmp = property(current_ingredient, "contained-in"); if (!tmp->atom - || !is_present_in_ingredients(caller, tmp->value) - || !is_present_in_products(caller, tmp->value)) + || (!is_present_in_ingredients(caller, tmp->value) + && !is_present_in_products(caller, tmp->value))) { raise << maybe(caller.name) << "/contained-in can only point to another ingredient or product, but got '" << to_string(property(current_ingredient, "contained-in")) << "'\n" << end(); + } continue; } + +:(scenario contained_in_check) +container test-list [ + value:num + next:&:test-list +] +def test-remove x:&:test-list/contained-in:result, from:&:test-list -> result:&:test-list [ + local-scope + load-ingredients + result <- copy 0 +] +$error: 0 diff --git a/064list.mu b/064list.mu index cf7be09c..baf3d7bf 100644 --- a/064list.mu +++ b/064list.mu @@ -8,11 +8,12 @@ container list:_elem [ next:&:list:_elem ] -def push x:_elem, in:&:list:_elem -> result:&:list:_elem [ +def push x:_elem, l:&:list:_elem -> l:&:list:_elem [ local-scope load-ingredients - result <- new {(list _elem): type} - *result <- merge x, in + result:&:list:_elem <- new {(list _elem): type} + *result <- merge x, l + reply result ] def first in:&:list:_elem -> result:_elem [ @@ -260,7 +261,7 @@ scenario removing-from-singleton-list [ # reverse the elements of a list # (contributed by Caleb Couch) -def reverse list:&:list:_elem temp:&:list:_elem -> result:&:list:_elem [ +def reverse list:&:list:_elem temp:&:list:_elem/contained-in:result -> result:&:list:_elem [ local-scope load-ingredients reply-unless list, temp |