about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-22 14:25:08 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-22 14:25:08 -0700
commit0d3a6f20f9de9716ef29b699b3221ed2dc149ecb (patch)
tree376120aea1d2f76a1be3f08c3283cb738caf2295
parent7e4692d4b874dcadab99ac5c03b1160ab0f4d9df (diff)
downloadmu-0d3a6f20f9de9716ef29b699b3221ed2dc149ecb.tar.gz
3406
Avoid spurious mutability errors due to index variables.
-rw-r--r--057immutable.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/057immutable.cc b/057immutable.cc
index 7fb9e052..4dc7a2aa 100644
--- a/057immutable.cc
+++ b/057immutable.cc
@@ -240,6 +240,18 @@ def foo a:&:@:&:num [
 ]
 $error: 0
 
+:(scenario latter_ingredient_of_index_is_immutable)
+def main [
+  # don't run anything
+]
+def foo a:&:@:&:@:num, b:num -> a:&:@:&:@:num [
+  local-scope
+  load-ingredients
+  x:&:@:num <- index *a, b
+  *x <- put-index *x, 0, 34
+]
+$error: 0
+
 :(scenario can_traverse_immutable_ingredients)
 container test-list [
   next:&:test-list
@@ -342,6 +354,7 @@ void check_immutable_ingredients(recipe_ordinal r) {
     for (int i = 0; i < SIZE(caller.steps); ++i) {
       const instruction& inst = caller.steps.at(i);
       check_immutable_ingredient_in_instruction(inst, immutable_vars, current_ingredient.name, caller);
+      if (inst.operation == INDEX && inst.ingredients.at(1).name == current_ingredient.name) continue;
       update_aliases(inst, immutable_vars);
     }
   }