diff options
Diffstat (limited to 'html/057immutable.cc.html')
-rw-r--r-- | html/057immutable.cc.html | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/html/057immutable.cc.html b/html/057immutable.cc.html index f54f4126..d3807446 100644 --- a/html/057immutable.cc.html +++ b/html/057immutable.cc.html @@ -66,7 +66,7 @@ if ('onhashchange' in window) { <span id="L6" class="LineNr"> 6 </span> <span id="L7" class="LineNr"> 7 </span><span class="Delimiter">:(scenario can_modify_ingredients_that_are_also_products)</span> <span id="L8" class="LineNr"> 8 </span><span class="Comment"># mutable container</span> -<span id="L9" class="LineNr"> 9 </span><span class="muRecipe">def</span> main [ +<span id="L9" class="LineNr"> 9 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L10" class="LineNr"> 10 </span> local-scope <span id="L11" class="LineNr"> 11 </span> <span class="Normal">p</span>:point<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span> <span id="L12" class="LineNr"> 12 </span> p<span class="Special"> <- </span>foo p @@ -74,12 +74,12 @@ if ('onhashchange' in window) { <span id="L14" class="LineNr"> 14 </span><span class="muRecipe">def</span> foo p:point<span class="muRecipe"> -> </span>p:point [ <span id="L15" class="LineNr"> 15 </span> local-scope <span id="L16" class="LineNr"> 16 </span> load-ingredients -<span id="L17" class="LineNr"> 17 </span> p<span class="Special"> <- </span>put p<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> +<span id="L17" class="LineNr"> 17 </span> p<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> p<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span id="L18" class="LineNr"> 18 </span>] <span id="L19" class="LineNr"> 19 </span>$error: <span class="Constant">0</span> <span id="L20" class="LineNr"> 20 </span> <span id="L21" class="LineNr"> 21 </span><span class="Delimiter">:(scenario can_modify_ingredients_that_are_also_products_2)</span> -<span id="L22" class="LineNr"> 22 </span><span class="muRecipe">def</span> main [ +<span id="L22" class="LineNr"> 22 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L23" class="LineNr"> 23 </span> local-scope <span id="L24" class="LineNr"> 24 </span> <span class="Normal">p</span>:&:point<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">point:type</span> <span id="L25" class="LineNr"> 25 </span> p<span class="Special"> <- </span>foo p @@ -88,12 +88,12 @@ if ('onhashchange' in window) { <span id="L28" class="LineNr"> 28 </span><span class="muRecipe">def</span> foo p:&:point<span class="muRecipe"> -> </span>p:&:point [ <span id="L29" class="LineNr"> 29 </span> local-scope <span id="L30" class="LineNr"> 30 </span> load-ingredients -<span id="L31" class="LineNr"> 31 </span> *p<span class="Special"> <- </span>put *p<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> +<span id="L31" class="LineNr"> 31 </span> *p<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> *p<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span id="L32" class="LineNr"> 32 </span>] <span id="L33" class="LineNr"> 33 </span>$error: <span class="Constant">0</span> <span id="L34" class="LineNr"> 34 </span> <span id="L35" class="LineNr"> 35 </span><span class="Delimiter">:(scenario can_modify_ingredients_that_are_also_products_3)</span> -<span id="L36" class="LineNr"> 36 </span><span class="muRecipe">def</span> main [ +<span id="L36" class="LineNr"> 36 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L37" class="LineNr"> 37 </span> local-scope <span id="L38" class="LineNr"> 38 </span> <span class="Normal">p</span>:&:@:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">number:type</span><span class="Delimiter">,</span> <span class="Constant">3</span> <span id="L39" class="LineNr"> 39 </span> p<span class="Special"> <- </span>foo p @@ -107,7 +107,7 @@ if ('onhashchange' in window) { <span id="L47" class="LineNr"> 47 </span>$error: <span class="Constant">0</span> <span id="L48" class="LineNr"> 48 </span> <span id="L49" class="LineNr"> 49 </span><span class="Delimiter">:(scenario ignore_literal_ingredients_for_immutability_checks)</span> -<span id="L50" class="LineNr"> 50 </span><span class="muRecipe">def</span> main [ +<span id="L50" class="LineNr"> 50 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L51" class="LineNr"> 51 </span> local-scope <span id="L52" class="LineNr"> 52 </span> <span class="Normal">p</span>:&:d1<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">d1:type</span> <span id="L53" class="LineNr"> 53 </span> <span class="Normal">q</span>:num<span class="Special"> <- </span>foo p @@ -116,7 +116,7 @@ if ('onhashchange' in window) { <span id="L56" class="LineNr"> 56 </span> local-scope <span id="L57" class="LineNr"> 57 </span> load-ingredients <span id="L58" class="LineNr"> 58 </span> <span class="Normal">x</span>:&:d1<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">d1:type</span> -<span id="L59" class="LineNr"> 59 </span> *x<span class="Special"> <- </span>put *x<span class="Delimiter">,</span> <span class="Constant">p:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span class="Comment"># ignore this 'p'</span> +<span id="L59" class="LineNr"> 59 </span> *x<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> *x<span class="Delimiter">,</span> <span class="Constant">p:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span class="Comment"># ignore this 'p'</span> <span id="L60" class="LineNr"> 60 </span> <span class="Identifier">return</span> <span class="Constant">36</span> <span id="L61" class="LineNr"> 61 </span>] <span id="L62" class="LineNr"> 62 </span><span class="muData">container</span> d1 [ @@ -127,7 +127,7 @@ if ('onhashchange' in window) { <span id="L67" class="LineNr"> 67 </span> <span id="L68" class="LineNr"> 68 </span><span class="Delimiter">:(scenario cannot_modify_immutable_ingredients)</span> <span id="L69" class="LineNr"> 69 </span><span class="Special">% Hide_errors = true;</span> -<span id="L70" class="LineNr"> 70 </span><span class="muRecipe">def</span> main [ +<span id="L70" class="LineNr"> 70 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L71" class="LineNr"> 71 </span> local-scope <span id="L72" class="LineNr"> 72 </span> <span class="Normal">x</span>:&:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> <span id="L73" class="LineNr"> 73 </span> foo x @@ -138,11 +138,11 @@ if ('onhashchange' in window) { <span id="L78" class="LineNr"> 78 </span> load-ingredients <span id="L79" class="LineNr"> 79 </span> *x<span class="Special"> <- </span>copy <span class="Constant">34</span> <span id="L80" class="LineNr"> 80 </span>] -<span id="L81" class="LineNr"> 81 </span><span class="traceContains">+error: foo: cannot modify 'x' in instruction '*x <- copy 34' because it's an ingredient of recipe foo but not also a product</span> +<span id="L81" class="LineNr"> 81 </span><span class="traceContains">+error: foo: cannot modify 'x' in <a href='010vm.cc.html#L32'>instruction</a> '*x <- copy 34' because it's an ingredient of recipe foo but not also a product</span> <span id="L82" class="LineNr"> 82 </span> <span id="L83" class="LineNr"> 83 </span><span class="Delimiter">:(scenario cannot_modify_immutable_containers)</span> <span id="L84" class="LineNr"> 84 </span><span class="Special">% Hide_errors = true;</span> -<span id="L85" class="LineNr"> 85 </span><span class="muRecipe">def</span> main [ +<span id="L85" class="LineNr"> 85 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L86" class="LineNr"> 86 </span> local-scope <span id="L87" class="LineNr"> 87 </span> <span class="Normal">x</span>:point-number<span class="Special"> <- </span>merge <span class="Constant">34</span><span class="Delimiter">,</span> <span class="Constant">35</span><span class="Delimiter">,</span> <span class="Constant">36</span> <span id="L88" class="LineNr"> 88 </span> foo x @@ -156,12 +156,12 @@ if ('onhashchange' in window) { <span id="L96" class="LineNr"> 96 </span> <span class="Comment"># modify the element: boom</span> <span id="L97" class="LineNr"> 97 </span> <span class="Comment"># This could be ok if y contains no addresses, but we're not going to try to be that smart.</span> <span id="L98" class="LineNr"> 98 </span> <span class="Comment"># It also makes the rules easier to reason about. If it's just an ingredient, just don't try to change it.</span> -<span id="L99" class="LineNr"> 99 </span> y<span class="Special"> <- </span>put y<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">37</span> +<span id="L99" class="LineNr"> 99 </span> y<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> y<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">37</span> <span id="L100" class="LineNr">100 </span>] -<span id="L101" class="LineNr">101 </span><span class="traceContains">+error: foo: cannot modify 'y' in instruction 'y <- put y, x:offset, 37' because that would modify 'x' which is an ingredient of recipe foo but not also a product</span> +<span id="L101" class="LineNr">101 </span><span class="traceContains">+error: foo: cannot modify 'y' in <a href='010vm.cc.html#L32'>instruction</a> 'y <- put y, x:offset, 37' because that would modify 'x' which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> foo but not also a product</span> <span id="L102" class="LineNr">102 </span> <span id="L103" class="LineNr">103 </span><span class="Delimiter">:(scenario can_modify_immutable_pointers)</span> -<span id="L104" class="LineNr">104 </span><span class="muRecipe">def</span> main [ +<span id="L104" class="LineNr">104 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L105" class="LineNr">105 </span> local-scope <span id="L106" class="LineNr">106 </span> <span class="Normal">x</span>:&:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> <span id="L107" class="LineNr">107 </span> foo x @@ -176,7 +176,7 @@ if ('onhashchange' in window) { <span id="L116" class="LineNr">116 </span> <span id="L117" class="LineNr">117 </span><span class="Delimiter">:(scenario can_modify_immutable_pointers_but_not_their_payloads)</span> <span id="L118" class="LineNr">118 </span><span class="Special">% Hide_errors = true;</span> -<span id="L119" class="LineNr">119 </span><span class="muRecipe">def</span> main [ +<span id="L119" class="LineNr">119 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L120" class="LineNr">120 </span> local-scope <span id="L121" class="LineNr">121 </span> <span class="Normal">x</span>:&:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> <span id="L122" class="LineNr">122 </span> foo x @@ -190,11 +190,11 @@ if ('onhashchange' in window) { <span id="L130" class="LineNr">130 </span> <span class="Comment"># this could be ok, but we're not going to try to be that smart</span> <span id="L131" class="LineNr">131 </span> *x<span class="Special"> <- </span>copy <span class="Constant">34</span> <span id="L132" class="LineNr">132 </span>] -<span id="L133" class="LineNr">133 </span><span class="traceContains">+error: foo: cannot modify 'x' in instruction '*x <- copy 34' because it's an ingredient of recipe foo but not also a product</span> +<span id="L133" class="LineNr">133 </span><span class="traceContains">+error: foo: cannot modify 'x' in <a href='010vm.cc.html#L32'>instruction</a> '*x <- copy 34' because it's an ingredient of recipe foo but not also a product</span> <span id="L134" class="LineNr">134 </span> <span id="L135" class="LineNr">135 </span><span class="Delimiter">:(scenario cannot_call_mutating_recipes_on_immutable_ingredients)</span> <span id="L136" class="LineNr">136 </span><span class="Special">% Hide_errors = true;</span> -<span id="L137" class="LineNr">137 </span><span class="muRecipe">def</span> main [ +<span id="L137" class="LineNr">137 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L138" class="LineNr">138 </span> local-scope <span id="L139" class="LineNr">139 </span> <span class="Normal">p</span>:&:point<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">point:type</span> <span id="L140" class="LineNr">140 </span> foo p @@ -210,11 +210,11 @@ if ('onhashchange' in window) { <span id="L150" class="LineNr">150 </span> <span class="Comment"># p could be modified here, but it doesn't have to be, it's already marked</span> <span id="L151" class="LineNr">151 </span> <span class="Comment"># mutable in the header</span> <span id="L152" class="LineNr">152 </span>] -<span id="L153" class="LineNr">153 </span><span class="traceContains">+error: foo: cannot modify 'p' in instruction 'bar p' because it's an ingredient of recipe foo but not also a product</span> +<span id="L153" class="LineNr">153 </span><span class="traceContains">+error: foo: cannot modify 'p' in <a href='010vm.cc.html#L32'>instruction</a> 'bar p' because it's an ingredient of recipe foo but not also a product</span> <span id="L154" class="LineNr">154 </span> <span id="L155" class="LineNr">155 </span><span class="Delimiter">:(scenario cannot_modify_copies_of_immutable_ingredients)</span> <span id="L156" class="LineNr">156 </span><span class="Special">% Hide_errors = true;</span> -<span id="L157" class="LineNr">157 </span><span class="muRecipe">def</span> main [ +<span id="L157" class="LineNr">157 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L158" class="LineNr">158 </span> local-scope <span id="L159" class="LineNr">159 </span> <span class="Normal">p</span>:&:point<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">point:type</span> <span id="L160" class="LineNr">160 </span> foo p @@ -223,12 +223,12 @@ if ('onhashchange' in window) { <span id="L163" class="LineNr">163 </span> local-scope <span id="L164" class="LineNr">164 </span> load-ingredients <span id="L165" class="LineNr">165 </span> <span class="Normal">q</span>:&:point<span class="Special"> <- </span>copy p -<span id="L166" class="LineNr">166 </span> *q<span class="Special"> <- </span>put *q<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> +<span id="L166" class="LineNr">166 </span> *q<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> *q<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span id="L167" class="LineNr">167 </span>] -<span id="L168" class="LineNr">168 </span><span class="traceContains">+error: foo: cannot modify 'q' in instruction '*q <- put *q, x:offset, 34' because that would modify p which is an ingredient of recipe foo but not also a product</span> +<span id="L168" class="LineNr">168 </span><span class="traceContains">+error: foo: cannot modify 'q' in <a href='010vm.cc.html#L32'>instruction</a> '*q <- put *q, x:offset, 34' because that would modify p which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> foo but not also a product</span> <span id="L169" class="LineNr">169 </span> <span id="L170" class="LineNr">170 </span><span class="Delimiter">:(scenario can_modify_copies_of_mutable_ingredients)</span> -<span id="L171" class="LineNr">171 </span><span class="muRecipe">def</span> main [ +<span id="L171" class="LineNr">171 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L172" class="LineNr">172 </span> local-scope <span id="L173" class="LineNr">173 </span> <span class="Normal">p</span>:&:point<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">point:type</span> <span id="L174" class="LineNr">174 </span> foo p @@ -237,7 +237,7 @@ if ('onhashchange' in window) { <span id="L177" class="LineNr">177 </span> local-scope <span id="L178" class="LineNr">178 </span> load-ingredients <span id="L179" class="LineNr">179 </span> <span class="Normal">q</span>:&:point<span class="Special"> <- </span>copy p -<span id="L180" class="LineNr">180 </span> *q<span class="Special"> <- </span>put *q<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> +<span id="L180" class="LineNr">180 </span> *q<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> *q<span class="Delimiter">,</span> <span class="Constant">x:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span id="L181" class="LineNr">181 </span>] <span id="L182" class="LineNr">182 </span>$error: <span class="Constant">0</span> <span id="L183" class="LineNr">183 </span> @@ -246,7 +246,7 @@ if ('onhashchange' in window) { <span id="L186" class="LineNr">186 </span><span class="muData">container</span> foo [ <span id="L187" class="LineNr">187 </span> <span class="Normal">x</span>:&:@:num <span class="Comment"># contains an address</span> <span id="L188" class="LineNr">188 </span>] -<span id="L189" class="LineNr">189 </span><span class="muRecipe">def</span> main [ +<span id="L189" class="LineNr">189 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L190" class="LineNr">190 </span> <span class="Comment"># don't run anything</span> <span id="L191" class="LineNr">191 </span>] <span id="L192" class="LineNr">192 </span><span class="muRecipe">def</span> foo a:&:foo [ @@ -255,13 +255,13 @@ if ('onhashchange' in window) { <span id="L195" class="LineNr">195 </span> <span class="Normal">x</span>:&:@:num<span class="Special"> <- </span>get *a<span class="Delimiter">,</span> <span class="Constant">x:offset</span> <span class="Comment"># just a regular get of the container</span> <span id="L196" class="LineNr">196 </span> *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> <span class="Comment"># but then a put-index on the result</span> <span id="L197" class="LineNr">197 </span>] -<span id="L198" class="LineNr">198 </span><span class="traceContains">+error: foo: cannot modify 'x' in instruction '*x <- put-index *x, 0, 34' because that would modify a which is an ingredient of recipe foo but not also a product</span> +<span id="L198" class="LineNr">198 </span><span class="traceContains">+error: foo: cannot modify 'x' in <a href='010vm.cc.html#L32'>instruction</a> '*x <- put-index *x, 0, 34' because that would modify a which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> foo but not also a product</span> <span id="L199" class="LineNr">199 </span> <span id="L200" class="LineNr">200 </span><span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_2)</span> <span id="L201" class="LineNr">201 </span><span class="muData">container</span> foo [ <span id="L202" class="LineNr">202 </span> <span class="Normal">x</span>:&:@:num <span class="Comment"># contains an address</span> <span id="L203" class="LineNr">203 </span>] -<span id="L204" class="LineNr">204 </span><span class="muRecipe">def</span> main [ +<span id="L204" class="LineNr">204 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L205" class="LineNr">205 </span> <span class="Comment"># don't run anything</span> <span id="L206" class="LineNr">206 </span>] <span id="L207" class="LineNr">207 </span><span class="muRecipe">def</span> foo a:&:foo [ @@ -276,7 +276,7 @@ if ('onhashchange' in window) { <span id="L216" class="LineNr">216 </span> <span id="L217" class="LineNr">217 </span><span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_3)</span> <span id="L218" class="LineNr">218 </span><span class="Special">% Hide_errors = true;</span> -<span id="L219" class="LineNr">219 </span><span class="muRecipe">def</span> main [ +<span id="L219" class="LineNr">219 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L220" class="LineNr">220 </span> <span class="Comment"># don't run anything</span> <span id="L221" class="LineNr">221 </span>] <span id="L222" class="LineNr">222 </span><span class="muRecipe">def</span> foo a:&:@:&:num [ @@ -285,16 +285,16 @@ if ('onhashchange' in window) { <span id="L225" class="LineNr">225 </span> <span class="Normal">x</span>:&:num<span class="Special"> <- </span>index *a<span class="Delimiter">,</span> <span class="Constant">0</span> <span class="Comment"># just a regular index of the array</span> <span id="L226" class="LineNr">226 </span> *x<span class="Special"> <- </span>copy <span class="Constant">34</span> <span class="Comment"># but then modify the result</span> <span id="L227" class="LineNr">227 </span>] -<span id="L228" class="LineNr">228 </span><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 id="L228" class="LineNr">228 </span><span class="traceContains">+error: foo: cannot modify 'x' in <a href='010vm.cc.html#L32'>instruction</a> '*x <- copy 34' because that would modify a which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> foo but not also a product</span> <span id="L229" class="LineNr">229 </span> <span id="L230" class="LineNr">230 </span><span class="Delimiter">:(scenario cannot_modify_address_inside_immutable_ingredients_4)</span> -<span id="L231" class="LineNr">231 </span><span class="muRecipe">def</span> main [ +<span id="L231" class="LineNr">231 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L232" class="LineNr">232 </span> <span class="Comment"># don't run anything</span> <span id="L233" class="LineNr">233 </span>] <span id="L234" class="LineNr">234 </span><span class="muRecipe">def</span> foo a:&:@:&:num [ <span id="L235" class="LineNr">235 </span> local-scope <span id="L236" class="LineNr">236 </span> load-ingredients -<span id="L237" class="LineNr">237 </span> <span class="Normal">b</span>:&:@:&:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">},</span> <span class="Constant">3</span> +<span id="L237" class="LineNr">237 </span> <span class="Normal">b</span>:&:@:&:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span><a href='043space.cc.html#L76'>address</a> number<span class="Delimiter">)</span>: type<span class="Delimiter">},</span> <span class="Constant">3</span> <span id="L238" class="LineNr">238 </span> <span class="Comment"># modify b, completely unrelated to immutable ingredient a</span> <span id="L239" class="LineNr">239 </span> <span class="Normal">x</span>:&:num<span class="Special"> <- </span>index *b<span class="Delimiter">,</span> <span class="Constant">0</span> <span id="L240" class="LineNr">240 </span> *x<span class="Special"> <- </span>copy <span class="Constant">34</span> @@ -302,7 +302,7 @@ if ('onhashchange' in window) { <span id="L242" class="LineNr">242 </span>$error: <span class="Constant">0</span> <span id="L243" class="LineNr">243 </span> <span id="L244" class="LineNr">244 </span><span class="Delimiter">:(scenario latter_ingredient_of_index_is_immutable)</span> -<span id="L245" class="LineNr">245 </span><span class="muRecipe">def</span> main [ +<span id="L245" class="LineNr">245 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L246" class="LineNr">246 </span> <span class="Comment"># don't run anything</span> <span id="L247" class="LineNr">247 </span>] <span id="L248" class="LineNr">248 </span><span class="muRecipe">def</span> foo a:&:@:&:@:num<span class="Delimiter">,</span> b:num<span class="muRecipe"> -> </span>a:&:@:&:@:num [ @@ -317,7 +317,7 @@ if ('onhashchange' in window) { <span id="L257" class="LineNr">257 </span><span class="muData">container</span> test-list [ <span id="L258" class="LineNr">258 </span> <span class="Normal">next</span>:&:test-list <span id="L259" class="LineNr">259 </span>] -<span id="L260" class="LineNr">260 </span><span class="muRecipe">def</span> main [ +<span id="L260" class="LineNr">260 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L261" class="LineNr">261 </span> local-scope <span id="L262" class="LineNr">262 </span> <span class="Normal">p</span>:&:test-list<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">test-list:type</span> <span id="L263" class="LineNr">263 </span> foo p @@ -335,7 +335,7 @@ if ('onhashchange' in window) { <span id="L275" class="LineNr">275 </span>$error: <span class="Constant">0</span> <span id="L276" class="LineNr">276 </span> <span id="L277" class="LineNr">277 </span><span class="Delimiter">:(scenario treat_optional_ingredients_as_mutable)</span> -<span id="L278" class="LineNr">278 </span><span class="muRecipe">def</span> main [ +<span id="L278" class="LineNr">278 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L279" class="LineNr">279 </span> <span class="Normal">k</span>:&:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> <span id="L280" class="LineNr">280 </span> test k <span id="L281" class="LineNr">281 </span>] @@ -356,7 +356,7 @@ if ('onhashchange' in window) { <span id="L296" class="LineNr">296 </span> <span id="L297" class="LineNr">297 </span><span class="Delimiter">:(scenario treat_optional_ingredients_as_mutable_2)</span> <span id="L298" class="LineNr">298 </span><span class="Special">% Hide_errors = true;</span> -<span id="L299" class="LineNr">299 </span><span class="muRecipe">def</span> main [ +<span id="L299" class="LineNr">299 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L300" class="LineNr">300 </span> local-scope <span id="L301" class="LineNr">301 </span> <span class="Normal">p</span>:&:point<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">point:type</span> <span id="L302" class="LineNr">302 </span> foo p @@ -371,11 +371,11 @@ if ('onhashchange' in window) { <span id="L311" class="LineNr">311 </span> load-ingredients <span id="L312" class="LineNr">312 </span> <span class="Normal">p</span>:&:point<span class="Special"> <- </span>next-ingredient <span class="Comment"># optional ingredient; assumed to be mutable</span> <span id="L313" class="LineNr">313 </span>] -<span id="L314" class="LineNr">314 </span><span class="traceContains">+error: foo: cannot modify 'p' in instruction 'bar p' because it's an ingredient of recipe foo but not also a product</span> +<span id="L314" class="LineNr">314 </span><span class="traceContains">+error: foo: cannot modify 'p' in <a href='010vm.cc.html#L32'>instruction</a> 'bar p' because it's an ingredient of recipe foo but not also a product</span> <span id="L315" class="LineNr">315 </span> <span id="L316" class="LineNr">316 </span><span class="Comment">//: when checking for immutable ingredients, remember to take space into account</span> <span id="L317" class="LineNr">317 </span><span class="Delimiter">:(scenario check_space_of_reagents_in_immutability_checks)</span> -<span id="L318" class="LineNr">318 </span><span class="muRecipe">def</span> main [ +<span id="L318" class="LineNr">318 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L319" class="LineNr">319 </span> <span class="Normal">a</span>:space<span class="Special"> <- </span><span class="Normal">new</span>-closure <span id="L320" class="LineNr">320 </span> <span class="Normal">b</span>:&:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">number:type</span> <span id="L321" class="LineNr">321 </span> run-closure b:&:num<span class="Delimiter">,</span> a:space @@ -395,39 +395,39 @@ if ('onhashchange' in window) { <span id="L335" class="LineNr">335 </span>$error: <span class="Constant">0</span> <span id="L336" class="LineNr">336 </span> <span id="L337" class="LineNr">337 </span><span class="Delimiter">:(before "End Transforms")</span> -<span id="L338" class="LineNr">338 </span>Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>check_immutable_ingredients<span class="Delimiter">);</span> <span class="Comment">// idempotent</span> +<span id="L338" class="LineNr">338 </span>Transform<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><a href='057immutable.cc.html#L341'>check_immutable_ingredients</a><span class="Delimiter">);</span> <span class="Comment">// idempotent</span> <span id="L339" class="LineNr">339 </span> <span id="L340" class="LineNr">340 </span><span class="Delimiter">:(code)</span> -<span id="L341" class="LineNr">341 </span><span class="Normal">void</span> check_immutable_ingredients<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L341" class="LineNr">341 </span><span class="Normal">void</span> <a href='057immutable.cc.html#L341'>check_immutable_ingredients</a><span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L342" class="LineNr">342 </span> <span class="Comment">// to ensure an address reagent isn't modified, it suffices to show that</span> <span id="L343" class="LineNr">343 </span> <span class="Comment">// a) we never write to its contents directly,</span> <span id="L344" class="LineNr">344 </span> <span class="Comment">// b) we never call 'put' or 'put-index' on it, and</span> <span id="L345" class="LineNr">345 </span> <span class="Comment">// c) any non-primitive recipe calls in the body aren't returning it as a product</span> <span id="L346" class="LineNr">346 </span> <span class="Normal">const</span> recipe& caller = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> -<span id="L347" class="LineNr">347 </span> trace<span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- check mutability of ingredients in recipe "</span> << caller<span class="Delimiter">.</span>name << end<span class="Delimiter">();</span> +<span id="L347" class="LineNr">347 </span> <a href='003trace.cc.html#L171'>trace</a><span class="Delimiter">(</span><span class="Constant">9991</span><span class="Delimiter">,</span> <span class="Constant">"transform"</span><span class="Delimiter">)</span> << <span class="Constant">"--- check mutability of ingredients in <a href='010vm.cc.html#L19'>recipe</a> "</span> << caller<span class="Delimiter">.</span>name << <a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> <span id="L348" class="LineNr">348 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!caller<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// skip check for old-style recipes calling next-ingredient directly</span> -<span id="L349" class="LineNr">349 </span> <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>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L349" class="LineNr">349 </span> <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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L350" class="LineNr">350 </span> <span class="Normal">const</span> reagent& current_ingredient = caller<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> -<span id="L351" class="LineNr">351 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_present_in_products<span class="Delimiter">(</span>caller<span class="Delimiter">,</span> current_ingredient<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not expected to be immutable</span> +<span id="L351" class="LineNr">351 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='057immutable.cc.html#L496'>is_present_in_products</a><span class="Delimiter">(</span>caller<span class="Delimiter">,</span> current_ingredient<span class="Delimiter">.</span>name<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not expected to be immutable</span> <span id="L352" class="LineNr">352 </span> <span class="Comment">// End Immutable Ingredients Special-cases</span> <span id="L353" class="LineNr">353 </span> set<reagent> immutable_vars<span class="Delimiter">;</span> <span id="L354" class="LineNr">354 </span> immutable_vars<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">);</span> -<span id="L355" class="LineNr">355 </span> <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 id="L355" class="LineNr">355 </span> <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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>steps<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L356" class="LineNr">356 </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> -<span id="L357" class="LineNr">357 </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 id="L358" class="LineNr">358 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation == INDEX && SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span> && 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> -<span id="L359" class="LineNr">359 </span> update_aliases<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> immutable_vars<span class="Delimiter">);</span> +<span id="L357" class="LineNr">357 </span> <a href='057immutable.cc.html#L438'>check_immutable_ingredient_in_instruction</a><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 id="L358" class="LineNr">358 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation == INDEX && <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span> && 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> +<span id="L359" class="LineNr">359 </span> <a href='057immutable.cc.html#L364'>update_aliases</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> immutable_vars<span class="Delimiter">);</span> <span id="L360" class="LineNr">360 </span> <span class="Delimiter">}</span> <span id="L361" class="LineNr">361 </span> <span class="Delimiter">}</span> <span id="L362" class="LineNr">362 </span><span class="Delimiter">}</span> <span id="L363" class="LineNr">363 </span> -<span id="L364" class="LineNr">364 </span><span class="Normal">void</span> update_aliases<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> set<reagent>& current_ingredient_and_aliases<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L365" class="LineNr">365 </span> set<<span class="Normal">int</span>> current_ingredient_indices = ingredient_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> +<span id="L364" class="LineNr">364 </span><span class="Normal">void</span> <a href='057immutable.cc.html#L364'>update_aliases</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> set<reagent>& current_ingredient_and_aliases<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L365" class="LineNr">365 </span> set<<span class="Normal">int</span>> current_ingredient_indices = <a href='057immutable.cc.html#L504'>ingredient_indices</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> <span id="L366" class="LineNr">366 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!contains_key<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L367" class="LineNr">367 </span> <span class="Comment">// primitive recipe</span> <span id="L368" class="LineNr">368 </span> <span class="Normal">switch</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L369" class="LineNr">369 </span> <span class="Normal">case</span> COPY: -<span id="L370" class="LineNr">370 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> +<span id="L369" class="LineNr">369 </span> <span class="Normal">case</span> <a href='010vm.cc.html#L190'>COPY</a>: +<span id="L370" class="LineNr">370 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span><a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span id="L371" class="LineNr">371 </span> current_ingredient_and_aliases<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>*p<span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span id="L372" class="LineNr">372 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L373" class="LineNr">373 </span> <span class="Normal">case</span> GET: @@ -444,26 +444,26 @@ if ('onhashchange' in window) { <span id="L384" class="LineNr">384 </span> <span class="Delimiter">}</span> <span id="L385" class="LineNr">385 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span id="L386" class="LineNr">386 </span> <span class="Comment">// defined recipe</span> -<span id="L387" class="LineNr">387 </span> set<<span class="Normal">int</span>> contained_in_product_indices = scan_contained_in_product_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_indices<span class="Delimiter">);</span> -<span id="L388" class="LineNr">388 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = contained_in_product_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != contained_in_product_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L389" class="LineNr">389 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*p < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> +<span id="L387" class="LineNr">387 </span> set<<span class="Normal">int</span>> contained_in_product_indices = <a href='057immutable.cc.html#L395'>scan_contained_in_product_indices</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_indices<span class="Delimiter">);</span> +<span id="L388" class="LineNr">388 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = contained_in_product_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != contained_in_product_indices<span class="Delimiter">.</span><a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L389" class="LineNr">389 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*p < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">))</span> <span id="L390" class="LineNr">390 </span> current_ingredient_and_aliases<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>*p<span class="Delimiter">));</span> <span id="L391" class="LineNr">391 </span> <span class="Delimiter">}</span> <span id="L392" class="LineNr">392 </span> <span class="Delimiter">}</span> <span id="L393" class="LineNr">393 </span><span class="Delimiter">}</span> <span id="L394" class="LineNr">394 </span> -<span id="L395" class="LineNr">395 </span>set<<span class="Normal">int</span>> scan_contained_in_product_indices<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> set<<span class="Normal">int</span>>& ingredient_indices<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L395" class="LineNr">395 </span>set<<span class="Normal">int</span>> <a href='057immutable.cc.html#L395'>scan_contained_in_product_indices</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> set<<span class="Normal">int</span>>& <a href='057immutable.cc.html#L504'>ingredient_indices</a><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L396" class="LineNr">396 </span> set<reagent> selected_ingredients<span class="Delimiter">;</span> <span id="L397" class="LineNr">397 </span> <span class="Normal">const</span> recipe& callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>operation<span class="Delimiter">);</span> -<span id="L398" class="LineNr">398 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L399" class="LineNr">399 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*p >= SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// optional immutable ingredient</span> +<span id="L398" class="LineNr">398 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = <a href='057immutable.cc.html#L504'>ingredient_indices</a><span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != <a href='057immutable.cc.html#L504'>ingredient_indices</a><span class="Delimiter">.</span><a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L399" class="LineNr">399 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>*p >= <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// optional immutable ingredient</span> <span id="L400" class="LineNr">400 </span> selected_ingredients<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>*p<span class="Delimiter">));</span> <span id="L401" class="LineNr">401 </span> <span class="Delimiter">}</span> <span id="L402" class="LineNr">402 </span> set<<span class="Normal">int</span>> result<span class="Delimiter">;</span> -<span id="L403" class="LineNr">403 </span> <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>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L403" class="LineNr">403 </span> <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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L404" class="LineNr">404 </span> <span class="Normal">const</span> reagent& current_product = callee<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L405" class="LineNr">405 </span> <span class="Normal">const</span> string_tree* contained_in_name = property<span class="Delimiter">(</span>current_product<span class="Delimiter">,</span> <span class="Constant">"contained-in"</span><span class="Delimiter">);</span> -<span id="L406" class="LineNr">406 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>contained_in_name && selected_ingredients<span class="Delimiter">.</span>find<span class="Delimiter">(</span>contained_in_name<span class="Delimiter">-></span>value<span class="Delimiter">)</span> != selected_ingredients<span class="Delimiter">.</span>end<span class="Delimiter">())</span> +<span id="L406" class="LineNr">406 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>contained_in_name && selected_ingredients<span class="Delimiter">.</span>find<span class="Delimiter">(</span>contained_in_name<span class="Delimiter">-></span>value<span class="Delimiter">)</span> != selected_ingredients<span class="Delimiter">.</span><a href='003trace.cc.html#L195'>end</a><span class="Delimiter">())</span> <span id="L407" class="LineNr">407 </span> result<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L408" class="LineNr">408 </span> <span class="Delimiter">}</span> <span id="L409" class="LineNr">409 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> @@ -476,7 +476,7 @@ if ('onhashchange' in window) { <span id="L416" class="LineNr">416 </span> <span class="Normal">value</span>:num <span id="L417" class="LineNr">417 </span> <span class="Normal">next</span>:&:test-list <span id="L418" class="LineNr">418 </span>] -<span id="L419" class="LineNr">419 </span><span class="muRecipe">def</span> main [ +<span id="L419" class="LineNr">419 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L420" class="LineNr">420 </span> local-scope <span id="L421" class="LineNr">421 </span> <span class="Normal">p</span>:&:test-list<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">test-list:type</span> <span id="L422" class="LineNr">422 </span> foo p @@ -485,33 +485,33 @@ if ('onhashchange' in window) { <span id="L425" class="LineNr">425 </span> local-scope <span id="L426" class="LineNr">426 </span> load-ingredients <span id="L427" class="LineNr">427 </span> <span class="Normal">p2</span>:&:test-list<span class="Special"> <- </span>test-next p <span class="Comment"># p2 is immutable</span> -<span id="L428" class="LineNr">428 </span> *p2<span class="Special"> <- </span>put *p2<span class="Delimiter">,</span> <span class="Constant">value:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> +<span id="L428" class="LineNr">428 </span> *p2<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> *p2<span class="Delimiter">,</span> <span class="Constant">value:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span id="L429" class="LineNr">429 </span>] <span id="L430" class="LineNr">430 </span><span class="muRecipe">def</span> test-next x:&:test-list<span class="muRecipe"> -> </span>y:&:test-list/contained-in:x [ <span id="L431" class="LineNr">431 </span> local-scope <span id="L432" class="LineNr">432 </span> load-ingredients <span id="L433" class="LineNr">433 </span> y<span class="Special"> <- </span>get *x<span class="Delimiter">,</span> <span class="Constant">next:offset</span> <span id="L434" class="LineNr">434 </span>] -<span id="L435" class="LineNr">435 </span><span class="traceContains">+error: foo: cannot modify 'p2' in instruction '*p2 <- put *p2, value:offset, 34' because that would modify p which is an ingredient of recipe foo but not also a product</span> +<span id="L435" class="LineNr">435 </span><span class="traceContains">+error: foo: cannot modify 'p2' in <a href='010vm.cc.html#L32'>instruction</a> '*p2 <- put *p2, value:offset, 34' because that would modify p which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> foo but not also a product</span> <span id="L436" class="LineNr">436 </span> <span id="L437" class="LineNr">437 </span><span class="Delimiter">:(code)</span> -<span id="L438" class="LineNr">438 </span><span class="Normal">void</span> check_immutable_ingredient_in_instruction<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> set<reagent>& current_ingredient_and_aliases<span class="Delimiter">,</span> <span class="Normal">const</span> string& original_ingredient_name<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L438" class="LineNr">438 </span><span class="Normal">void</span> <a href='057immutable.cc.html#L438'>check_immutable_ingredient_in_instruction</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> set<reagent>& current_ingredient_and_aliases<span class="Delimiter">,</span> <span class="Normal">const</span> string& original_ingredient_name<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L439" class="LineNr">439 </span> <span class="Comment">// first check if the instruction is directly modifying something it shouldn't</span> -<span id="L440" class="LineNr">440 </span> <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>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L440" class="LineNr">440 </span> <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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L441" class="LineNr">441 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"lookup"</span><span class="Delimiter">)</span> -<span id="L442" class="LineNr">442 </span> && current_ingredient_and_aliases<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != current_ingredient_and_aliases<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> +<span id="L442" class="LineNr">442 </span> && current_ingredient_and_aliases<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != current_ingredient_and_aliases<span class="Delimiter">.</span><a href='003trace.cc.html#L195'>end</a><span class="Delimiter">())</span> <span class="Delimiter">{</span> <span id="L443" class="LineNr">443 </span> string current_product_name = inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name<span class="Delimiter">;</span> <span id="L444" class="LineNr">444 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_product_name == original_ingredient_name<span class="Delimiter">)</span> -<span id="L445" class="LineNr">445 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_product_name << <span class="Constant">"' in instruction '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because it's an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L445" class="LineNr">445 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_product_name << <span class="Constant">"' in <a href='010vm.cc.html#L32'>instruction</a> '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because it's an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span id="L446" class="LineNr">446 </span> <span class="Normal">else</span> -<span id="L447" class="LineNr">447 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_product_name << <span class="Constant">"' in instruction '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because that would modify "</span> << original_ingredient_name << <span class="Constant">" which is an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L447" class="LineNr">447 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_product_name << <span class="Constant">"' in <a href='010vm.cc.html#L32'>instruction</a> '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because that would modify "</span> << original_ingredient_name << <span class="Constant">" which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> <span id="L448" class="LineNr">448 </span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L449" class="LineNr">449 </span> <span class="Delimiter">}</span> <span id="L450" class="LineNr">450 </span> <span class="Delimiter">}</span> <span id="L451" class="LineNr">451 </span> <span class="Comment">// check if there's any indirect modification going on</span> -<span id="L452" class="LineNr">452 </span> set<<span class="Normal">int</span>> current_ingredient_indices = ingredient_indices<span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> +<span id="L452" class="LineNr">452 </span> set<<span class="Normal">int</span>> current_ingredient_indices = <a href='057immutable.cc.html#L504'>ingredient_indices</a><span class="Delimiter">(</span>inst<span class="Delimiter">,</span> current_ingredient_and_aliases<span class="Delimiter">);</span> <span id="L453" class="LineNr">453 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_ingredient_indices<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Comment">// ingredient not found in call</span> -<span id="L454" class="LineNr">454 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span>end<span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L454" class="LineNr">454 </span> <span class="Normal">for</span> <span class="Delimiter">(</span>set<<span class="Normal">int</span>>::iterator p = current_ingredient_indices<span class="Delimiter">.</span>begin<span class="Delimiter">();</span> p != current_ingredient_indices<span class="Delimiter">.</span><a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> ++p<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L455" class="LineNr">455 </span> <span class="Normal">const</span> <span class="Normal">int</span> current_ingredient_index = *p<span class="Delimiter">;</span> <span id="L456" class="LineNr">456 </span> reagent current_ingredient = inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>current_ingredient_index<span class="Delimiter">);</span> <span id="L457" class="LineNr">457 </span> canonize_type<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">);</span> @@ -525,47 +525,47 @@ if ('onhashchange' in window) { <span id="L465" class="LineNr">465 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation == PUT || inst<span class="Delimiter">.</span>operation == PUT_INDEX<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L466" class="LineNr">466 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_ingredient_index == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L467" class="LineNr">467 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_ingredient_name == original_ingredient_name<span class="Delimiter">)</span> -<span id="L468" class="LineNr">468 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in instruction '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because it's an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L468" class="LineNr">468 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in <a href='010vm.cc.html#L32'>instruction</a> '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because it's an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span id="L469" class="LineNr">469 </span> <span class="Normal">else</span> -<span id="L470" class="LineNr">470 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in instruction '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because that would modify '"</span> << original_ingredient_name << <span class="Constant">"' which is an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L470" class="LineNr">470 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in <a href='010vm.cc.html#L32'>instruction</a> '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because that would modify '"</span> << original_ingredient_name << <span class="Constant">"' which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> <span id="L471" class="LineNr">471 </span> <span class="Delimiter">}</span> <span id="L472" class="LineNr">472 </span> <span class="Delimiter">}</span> <span id="L473" class="LineNr">473 </span> <span class="Delimiter">}</span> <span id="L474" class="LineNr">474 </span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span id="L475" class="LineNr">475 </span> <span class="Comment">// defined recipe</span> -<span id="L476" class="LineNr">476 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_modified_in_recipe<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation<span class="Delimiter">,</span> current_ingredient_index<span class="Delimiter">,</span> caller<span class="Delimiter">))</span> <span class="Delimiter">{</span> +<span id="L476" class="LineNr">476 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='057immutable.cc.html#L486'>is_modified_in_recipe</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>operation<span class="Delimiter">,</span> current_ingredient_index<span class="Delimiter">,</span> caller<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span id="L477" class="LineNr">477 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>current_ingredient_name == original_ingredient_name<span class="Delimiter">)</span> -<span id="L478" class="LineNr">478 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in instruction '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because it's an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L478" class="LineNr">478 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in <a href='010vm.cc.html#L32'>instruction</a> '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because it's an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span id="L479" class="LineNr">479 </span> <span class="Normal">else</span> -<span id="L480" class="LineNr">480 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in instruction '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because that would modify '"</span> << original_ingredient_name << <span class="Constant">"' which is an ingredient of recipe "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L480" class="LineNr">480 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"cannot modify '"</span> << current_ingredient_name << <span class="Constant">"' in <a href='010vm.cc.html#L32'>instruction</a> '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' because that would modify '"</span> << original_ingredient_name << <span class="Constant">"' which is an ingredient of <a href='010vm.cc.html#L19'>recipe</a> "</span> << caller<span class="Delimiter">.</span>name << <span class="Constant">" but not also a product</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> <span id="L481" class="LineNr">481 </span> <span class="Delimiter">}</span> <span id="L482" class="LineNr">482 </span> <span class="Delimiter">}</span> <span id="L483" class="LineNr">483 </span> <span class="Delimiter">}</span> <span id="L484" class="LineNr">484 </span><span class="Delimiter">}</span> <span id="L485" class="LineNr">485 </span> -<span id="L486" class="LineNr">486 </span><span class="Normal">bool</span> is_modified_in_recipe<span class="Delimiter">(</span><span class="Normal">const</span> recipe_ordinal r<span class="Delimiter">,</span> <span class="Normal">const</span> <span class="Normal">int</span> ingredient_index<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L486" class="LineNr">486 </span><span class="Normal">bool</span> <a href='057immutable.cc.html#L486'>is_modified_in_recipe</a><span class="Delimiter">(</span><span class="Normal">const</span> <a href='010vm.cc.html#L14'>recipe_ordinal</a> r<span class="Delimiter">,</span> <span class="Normal">const</span> <span class="Normal">int</span> ingredient_index<span class="Delimiter">,</span> <span class="Normal">const</span> recipe& caller<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L487" class="LineNr">487 </span> <span class="Normal">const</span> recipe& callee = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span id="L488" class="LineNr">488 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!callee<span class="Delimiter">.</span>has_header<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L489" class="LineNr">489 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"can't check mutability of ingredients in recipe "</span> << callee<span class="Delimiter">.</span>name << <span class="Constant">" because it uses 'next-ingredient' directly, rather than a recipe header.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L489" class="LineNr">489 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"can't check mutability of ingredients in recipe "</span> << callee<span class="Delimiter">.</span>name << <span class="Constant">" because it uses 'next-ingredient' directly, rather than a recipe header.</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span id="L490" class="LineNr">490 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L491" class="LineNr">491 </span> <span class="Delimiter">}</span> -<span id="L492" class="LineNr">492 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_index >= SIZE<span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// optional immutable ingredient</span> -<span id="L493" class="LineNr">493 </span> <span class="Identifier">return</span> is_present_in_products<span class="Delimiter">(</span>callee<span class="Delimiter">,</span> callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>name<span class="Delimiter">);</span> +<span id="L492" class="LineNr">492 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_index >= <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">))</span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span class="Comment">// optional immutable ingredient</span> +<span id="L493" class="LineNr">493 </span> <span class="Identifier">return</span> <a href='057immutable.cc.html#L496'>is_present_in_products</a><span class="Delimiter">(</span>callee<span class="Delimiter">,</span> callee<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>ingredient_index<span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span id="L494" class="LineNr">494 </span><span class="Delimiter">}</span> <span id="L495" class="LineNr">495 </span> -<span id="L496" class="LineNr">496 </span><span class="Normal">bool</span> is_present_in_products<span class="Delimiter">(</span><span class="Normal">const</span> recipe& callee<span class="Delimiter">,</span> <span class="Normal">const</span> string& ingredient_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L497" class="LineNr">497 </span> <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>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L496" class="LineNr">496 </span><span class="Normal">bool</span> <a href='057immutable.cc.html#L496'>is_present_in_products</a><span class="Delimiter">(</span><span class="Normal">const</span> recipe& callee<span class="Delimiter">,</span> <span class="Normal">const</span> string& ingredient_name<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L497" class="LineNr">497 </span> <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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L498" class="LineNr">498 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>callee<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>name == ingredient_name<span class="Delimiter">)</span> <span id="L499" class="LineNr">499 </span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span id="L500" class="LineNr">500 </span> <span class="Delimiter">}</span> <span id="L501" class="LineNr">501 </span> <span class="Identifier">return</span> <span class="Constant">false</span><span class="Delimiter">;</span> <span id="L502" class="LineNr">502 </span><span class="Delimiter">}</span> <span id="L503" class="LineNr">503 </span> -<span id="L504" class="LineNr">504 </span>set<<span class="Normal">int</span>> ingredient_indices<span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> set<reagent>& ingredient_names<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L504" class="LineNr">504 </span>set<<span class="Normal">int</span>> <a href='057immutable.cc.html#L504'>ingredient_indices</a><span class="Delimiter">(</span><span class="Normal">const</span> instruction& inst<span class="Delimiter">,</span> <span class="Normal">const</span> set<reagent>& ingredient_names<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L505" class="LineNr">505 </span> set<<span class="Normal">int</span>> result<span class="Delimiter">;</span> -<span id="L506" class="LineNr">506 </span> <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>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span id="L506" class="LineNr">506 </span> <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 < <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L507" class="LineNr">507 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> -<span id="L508" class="LineNr">508 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_names<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != ingredient_names<span class="Delimiter">.</span>end<span class="Delimiter">())</span> +<span id="L508" class="LineNr">508 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>ingredient_names<span class="Delimiter">.</span>find<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> != ingredient_names<span class="Delimiter">.</span><a href='003trace.cc.html#L195'>end</a><span class="Delimiter">())</span> <span id="L509" class="LineNr">509 </span> result<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L510" class="LineNr">510 </span> <span class="Delimiter">}</span> <span id="L511" class="LineNr">511 </span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> @@ -588,7 +588,7 @@ if ('onhashchange' in window) { <span id="L528" class="LineNr">528 </span> <span class="Normal">value</span>:num <span id="L529" class="LineNr">529 </span> <span class="Normal">next</span>:&:test-list <span id="L530" class="LineNr">530 </span>] -<span id="L531" class="LineNr">531 </span><span class="muRecipe">def</span> main [ +<span id="L531" class="LineNr">531 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L532" class="LineNr">532 </span> local-scope <span id="L533" class="LineNr">533 </span> <span class="Normal">p</span>:&:test-list<span class="Special"> <- </span><span class="Normal">new</span> <span class="Constant">test-list:type</span> <span id="L534" class="LineNr">534 </span> foo p @@ -607,7 +607,7 @@ if ('onhashchange' in window) { <span id="L547" class="LineNr">547 </span><span class="muRecipe">def</span> test-remove x:&:test-list/contained-in:from<span class="Delimiter">,</span> from:&:test-list<span class="muRecipe"> -> </span>from:&:test-list [ <span id="L548" class="LineNr">548 </span> local-scope <span id="L549" class="LineNr">549 </span> load-ingredients -<span id="L550" class="LineNr">550 </span> *x<span class="Special"> <- </span>put *x<span class="Delimiter">,</span> <span class="Constant">value:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span class="Comment"># can modify x</span> +<span id="L550" class="LineNr">550 </span> *x<span class="Special"> <- </span><a href='001help.cc.html#L218'>put</a> *x<span class="Delimiter">,</span> <span class="Constant">value:offset</span><span class="Delimiter">,</span> <span class="Constant">34</span> <span class="Comment"># can modify x</span> <span id="L551" class="LineNr">551 </span>] <span id="L552" class="LineNr">552 </span>$error: <span class="Constant">0</span> <span id="L553" class="LineNr">553 </span> @@ -617,7 +617,7 @@ if ('onhashchange' in window) { <span id="L557" class="LineNr">557 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!tmp<span class="Delimiter">-></span>atom <span id="L558" class="LineNr">558 </span> || <span class="Delimiter">(</span>!is_present_in_ingredients<span class="Delimiter">(</span>caller<span class="Delimiter">,</span> tmp<span class="Delimiter">-></span>value<span class="Delimiter">)</span> <span id="L559" class="LineNr">559 </span> && !is_present_in_products<span class="Delimiter">(</span>caller<span class="Delimiter">,</span> tmp<span class="Delimiter">-></span>value<span class="Delimiter">)))</span> <span class="Delimiter">{</span> -<span id="L560" class="LineNr">560 </span> raise << maybe<span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"/contained-in can only point to another ingredient or product, but got '"</span> << to_string<span class="Delimiter">(</span>property<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">,</span> <span class="Constant">"contained-in"</span><span class="Delimiter">))</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> +<span id="L560" class="LineNr">560 </span> <a href='003trace.cc.html#L178'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>caller<span class="Delimiter">.</span>name<span class="Delimiter">)</span> << <span class="Constant">"/contained-in can only point to another ingredient or product, but got '"</span> << to_string<span class="Delimiter">(</span>property<span class="Delimiter">(</span>current_ingredient<span class="Delimiter">,</span> <span class="Constant">"contained-in"</span><span class="Delimiter">))</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L195'>end</a><span class="Delimiter">();</span> <span id="L561" class="LineNr">561 </span> <span class="Delimiter">}</span> <span id="L562" class="LineNr">562 </span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span id="L563" class="LineNr">563 </span><span class="Delimiter">}</span> |