diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-23 23:07:58 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-23 23:07:58 -0700 |
commit | 203563b3465fe5f25f97e475b1a4dbe957845030 (patch) | |
tree | f6112083d29a9639109e2cde7e3075a36e3cb1b5 /html/057immutable.cc.html | |
parent | d587411f9da46f72cd99c966cfe3150b5e72baab (diff) | |
download | mu-203563b3465fe5f25f97e475b1a4dbe957845030.tar.gz |
3412
Diffstat (limited to 'html/057immutable.cc.html')
-rw-r--r-- | html/057immutable.cc.html | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/html/057immutable.cc.html b/html/057immutable.cc.html index b74dbcb5..94d6d42f 100644 --- a/html/057immutable.cc.html +++ b/html/057immutable.cc.html @@ -250,9 +250,6 @@ $error: <span class="Constant">0</span> <span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_3)</span> <span class="Special">% Hide_errors = true;</span> -container foo [ - <span class="Normal">x</span>:num -] def main [ <span class="Comment"># don't run anything</span> ] @@ -265,9 +262,6 @@ def foo a:&:@:&:num [ <span class="traceContains">+error: foo: cannot modify 'x' in instruction '*x <- copy 34' because that would modify a which is an ingredient of recipe foo but not also a product</span> <span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_4)</span> -container foo [ - <span class="Normal">x</span>:&:@:num <span class="Comment"># contains an address</span> -] def main [ <span class="Comment"># don't run anything</span> ] @@ -281,6 +275,18 @@ def foo a:&:@:&:num [ ] $error: <span class="Constant">0</span> +<span class="Delimiter">:(scenario latter_ingredient_of_index_is_immutable)</span> +def main [ + <span class="Comment"># don't run anything</span> +] +def foo a:&:@:&:@:num<span class="Delimiter">,</span> b:num <span class="Delimiter">-></span> a:&:@:&:@:num [ + local-scope + load-ingredients + <span class="Normal">x</span>:&:@:num<span class="Special"> <- </span>index *a<span class="Delimiter">,</span> b + *x<span class="Special"> <- </span>put-index *x<span class="Delimiter">,</span> <span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">34</span> +] +$error: <span class="Constant">0</span> + <span class="Delimiter">:(scenario can_traverse_immutable_ingredients)</span> container test-list [ <span class="Normal">next</span>:&:test-list @@ -383,6 +389,7 @@ Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</spa <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">const</span> instruction& inst = caller<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> check_immutable_ingredient_in_instruction<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> immutable_vars<span class="Delimiter">,</span> current_ingredient<span class="Delimiter">.</span>name<span class="Delimiter">,</span> caller<span class="Delimiter">);</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation == INDEX && inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name == current_ingredient<span class="Delimiter">.</span>name<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> update_aliases<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> immutable_vars<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> |