1 //: Advanced notation for the common/easy case where a recipe takes some fixed
2 //: number of ingredients and yields some fixed number of products.
4 void test_recipe_with_header() {
7 " 1:num/raw <- add2 3, 5\n"
9 "def add2 x:num, y:num -> z:num [\n"
12 " z:num <- add x, y\n"
17 "mem: storing 8 in location 1\n"
21 //: When loading recipes save any header.
23 :(before
"End recipe Fields")
25 vector
<reagent
> ingredients
;
26 vector
<reagent
> products
;
27 :(before
"End recipe Constructor")
30 :(before
"End Recipe Refinements")
31 if (in
.peek() != '[') {
32 trace(101, "parse") << "recipe has a header; parsing" << end();
33 load_recipe_header(in
, result
);
37 void load_recipe_header(istream
& in
, recipe
& result
) {
38 result
.has_header
= true;
39 while (has_data(in
) && in
.peek() != '[' && in
.peek() != '\n') {
40 string s
= next_word(in
);
42 assert(!has_data(in
));
43 raise
<< "incomplete recipe header at end of file (0)\n" << end();
47 raise
<< "recipe " << result
.name
<< " should say '->' and not '<-'\n" << end();
49 result
.ingredients
.push_back(reagent(s
));
50 trace(101, "parse") << "header ingredient: " << result
.ingredients
.back().original_string
<< end();
51 skip_whitespace_but_not_newline(in
);
53 while (has_data(in
) && in
.peek() != '[' && in
.peek() != '\n') {
54 string s
= next_word(in
);
56 assert(!has_data(in
));
57 raise
<< "incomplete recipe header at end of file (1)\n" << end();
60 result
.products
.push_back(reagent(s
));
61 trace(101, "parse") << "header product: " << result
.products
.back().original_string
<< end();
62 skip_whitespace_but_not_newline(in
);
64 // End Load Recipe Header(result)
67 void test_recipe_handles_stray_comma() {
70 " 1:num/raw <- add2 3, 5\n"
72 "def add2 x:num, y:num -> z:num, [\n"
75 " z:num <- add x, y\n"
80 "mem: storing 8 in location 1\n"
84 void test_recipe_handles_stray_comma_2() {
90 " 1:num/raw <- add 2, 2\n"
93 " 1:num/raw <- add 2, 3\n"
97 "mem: storing 4 in location 1\n"
101 void test_recipe_handles_wrong_arrow() {
104 "def foo a:num <- b:num [\n"
107 CHECK_TRACE_CONTENTS(
108 "error: recipe foo should say '->' and not '<-'\n"
112 void test_recipe_handles_missing_bracket() {
118 CHECK_TRACE_CONTENTS(
119 "error: main: recipe body must begin with '['\n"
123 void test_recipe_handles_missing_bracket_2() {
132 // doesn't overflow line when reading header
133 CHECK_TRACE_DOESNT_CONTAIN("parse: header ingredient: local-scope");
134 CHECK_TRACE_CONTENTS(
135 "error: main: recipe body must begin with '['\n"
139 void test_recipe_handles_missing_bracket_3() {
142 "def main # comment\n"
148 // doesn't overflow line when reading header
149 CHECK_TRACE_DOESNT_CONTAIN("parse: header ingredient: local-scope");
150 CHECK_TRACE_CONTENTS(
151 "error: main: recipe body must begin with '['\n"
155 :(after
"Begin debug_string(recipe x)")
156 out
<< "ingredients:\n";
157 for (int i
= 0; i
< SIZE(x
.ingredients
); ++i
)
158 out
<< " " << debug_string(x
.ingredients
.at(i
)) << '\n';
159 out
<< "products:\n";
160 for (int i
= 0; i
< SIZE(x
.products
); ++i
)
161 out
<< " " << debug_string(x
.products
.at(i
)) << '\n';
163 //: If a recipe never mentions any ingredients or products, assume it has a header.
166 void test_recipe_without_ingredients_or_products_has_header() {
169 " 1:num <- copy 34\n"
172 CHECK_TRACE_CONTENTS(
173 "parse: recipe test has a header\n"
177 :(before
"End Recipe Body(result)")
178 if (!result
.has_header
) {
179 result
.has_header
= true;
180 for (int i
= 0; i
< SIZE(result
.steps
); ++i
) {
181 const instruction
& inst
= result
.steps
.at(i
);
182 if ((inst
.name
== "reply" && !inst
.ingredients
.empty())
183 || (inst
.name
== "return" && !inst
.ingredients
.empty())
184 || inst
.name
== "next-ingredient"
185 || inst
.name
== "ingredient"
186 || inst
.name
== "rewind-ingredients") {
187 result
.has_header
= false;
192 if (result
.has_header
) {
193 trace(101, "parse") << "recipe " << result
.name
<< " has a header" << end();
196 //: Support type abbreviations in headers.
199 void test_type_abbreviations_in_recipe_headers() {
204 " 1:char/raw <- index *a, 0\n"
206 "def foo -> a:text [ # 'text' is an abbreviation\n"
208 " load-ingredients\n"
212 CHECK_TRACE_CONTENTS(
213 "mem: storing 97 in location 1\n"
217 :(before
"End Expand Type Abbreviations(caller)")
218 for (long int i
= 0; i
< SIZE(caller
.ingredients
); ++i
)
219 expand_type_abbreviations(caller
.ingredients
.at(i
).type
);
220 for (long int i
= 0; i
< SIZE(caller
.products
); ++i
)
221 expand_type_abbreviations(caller
.products
.at(i
).type
);
223 //: Rewrite 'load-ingredients' to instructions to create all reagents in the header.
225 :(before
"End Rewrite Instruction(curr, recipe result)")
226 if (curr
.name
== "load-ingredients" || curr
.name
== "load-inputs") {
228 recipe_ordinal op
= get(Recipe_ordinal
, "next-ingredient-without-typechecking");
229 for (int i
= 0; i
< SIZE(result
.ingredients
); ++i
) {
231 curr
.name
= "next-ingredient-without-typechecking";
232 curr
.products
.push_back(result
.ingredients
.at(i
));
233 result
.steps
.push_back(curr
);
237 if (curr
.name
== "next-ingredient-without-typechecking") {
238 raise
<< maybe(result
.name
) << "never call 'next-ingredient-without-typechecking' directly\n" << end();
242 //: internal version of next-ingredient; don't call this directly
243 :(before
"End Primitive Recipe Declarations")
244 NEXT_INGREDIENT_WITHOUT_TYPECHECKING
,
245 :(before
"End Primitive Recipe Numbers")
246 put(Recipe_ordinal
, "next-ingredient-without-typechecking", NEXT_INGREDIENT_WITHOUT_TYPECHECKING
);
247 :(before
"End Primitive Recipe Checks")
248 case NEXT_INGREDIENT_WITHOUT_TYPECHECKING
: {
251 :(before
"End Primitive Recipe Implementations")
252 case NEXT_INGREDIENT_WITHOUT_TYPECHECKING
: {
253 assert(!Current_routine
->calls
.empty());
254 if (current_call().next_ingredient_to_process
< SIZE(current_call().ingredient_atoms
)) {
256 current_call().ingredient_atoms
.at(current_call().next_ingredient_to_process
));
257 assert(SIZE(products
) == 1); products
.resize(2); // push a new vector
258 products
.at(1).push_back(1);
259 ++current_call().next_ingredient_to_process
;
263 // pad the first product with sufficient zeros to match its type
264 products
.at(0).resize(size_of(current_instruction().products
.at(0)));
265 products
.at(1).push_back(0);
270 //: more useful error messages if someone forgets 'load-ingredients'
272 void test_load_ingredients_missing_error() {
277 " b:num <- add a:num, 1\n"
280 CHECK_TRACE_CONTENTS(
281 "error: foo: tried to read ingredient 'a' in 'b:num <- add a:num, 1' but it hasn't been written to yet\n"
282 "error: did you forget 'load-ingredients'?\n"
286 :(after
"use-before-set Error")
287 if (is_present_in_ingredients(caller
, ingredient
.name
))
288 raise
<< " did you forget 'load-ingredients'?\n" << end();
291 void test_load_ingredients_missing_error_2() {
296 " b:num <- add a, 1\n"
299 CHECK_TRACE_CONTENTS(
300 "error: foo: missing type for 'a' in 'b:num <- add a, 1'\n"
301 "error: did you forget 'load-ingredients'?\n"
305 :(after
"missing-type Error 1")
306 if (is_present_in_ingredients(get(Recipe
, get(Recipe_ordinal
, recipe_name
)), x
.name
))
307 raise
<< " did you forget 'load-ingredients'?\n" << end();
310 bool is_present_in_ingredients(const recipe
& callee
, const string
& ingredient_name
) {
311 for (int i
= 0; i
< SIZE(callee
.ingredients
); ++i
) {
312 if (callee
.ingredients
.at(i
).name
== ingredient_name
)
318 //:: Check all calls against headers.
320 void test_show_clear_error_on_bad_call() {
326 "def foo x:point -> y:num [\n"
328 " load-ingredients\n"
332 CHECK_TRACE_CONTENTS(
333 "error: main: ingredient 0 has the wrong type at '1:num <- foo 34'\n"
337 void test_show_clear_error_on_bad_call_2() {
341 " 1:point <- foo 34\n"
343 "def foo x:num -> y:num [\n"
345 " load-ingredients\n"
349 CHECK_TRACE_CONTENTS(
350 "error: main: product 0 has the wrong type at '1:point <- foo 34'\n"
354 :(after
"Transform.push_back(check_instruction)")
355 Transform
.push_back(check_calls_against_header
); // idempotent
357 void check_calls_against_header(const recipe_ordinal r
) {
358 const recipe
& caller
= get(Recipe
, r
);
359 trace(101, "transform") << "--- type-check calls inside recipe " << caller
.name
<< end();
360 for (int i
= 0; i
< SIZE(caller
.steps
); ++i
) {
361 const instruction
& inst
= caller
.steps
.at(i
);
362 if (is_primitive(inst
.operation
)) continue;
363 const recipe
& callee
= get(Recipe
, inst
.operation
);
364 if (!callee
.has_header
) continue;
365 for (long int i
= 0; i
< min(SIZE(inst
.ingredients
), SIZE(callee
.ingredients
)); ++i
) {
366 // ingredients coerced from call to callee
367 if (!types_coercible(callee
.ingredients
.at(i
), inst
.ingredients
.at(i
))) {
368 raise
<< maybe(caller
.name
) << "ingredient " << i
<< " has the wrong type at '" << to_original_string(inst
) << "'\n" << end();
369 raise
<< " ['" << to_string(callee
.ingredients
.at(i
).type
) << "' vs '" << to_string(inst
.ingredients
.at(i
).type
) << "']\n" << end();
372 for (long int i
= 0; i
< min(SIZE(inst
.products
), SIZE(callee
.products
)); ++i
) {
373 if (is_dummy(inst
.products
.at(i
))) continue;
374 // products coerced from callee to call
375 if (!types_coercible(inst
.products
.at(i
), callee
.products
.at(i
))) {
376 raise
<< maybe(caller
.name
) << "product " << i
<< " has the wrong type at '" << to_original_string(inst
) << "'\n" << end();
377 raise
<< " ['" << to_string(inst
.products
.at(i
).type
) << "' vs '" << to_string(callee
.products
.at(i
).type
) << "']\n" << end();
383 //:: Check types going in and out of all recipes with headers.
385 void test_recipe_headers_are_checked() {
388 "def add2 x:num, y:num -> z:num [\n"
390 " load-ingredients\n"
391 " z:&:num <- copy 0/unsafe\n"
395 CHECK_TRACE_CONTENTS(
396 "error: add2: replied with the wrong type at 'return z'\n"
400 :(before
"End Checks")
401 Transform
.push_back(check_return_instructions_against_header
); // idempotent
404 void check_return_instructions_against_header(const recipe_ordinal r
) {
405 const recipe
& caller_recipe
= get(Recipe
, r
);
406 if (!caller_recipe
.has_header
) return;
407 trace(101, "transform") << "--- checking return instructions against header for " << caller_recipe
.name
<< end();
408 for (int i
= 0; i
< SIZE(caller_recipe
.steps
); ++i
) {
409 const instruction
& inst
= caller_recipe
.steps
.at(i
);
410 if (inst
.name
!= "reply" && inst
.name
!= "return") continue;
411 if (SIZE(caller_recipe
.products
) != SIZE(inst
.ingredients
)) {
412 raise
<< maybe(caller_recipe
.name
) << "replied with the wrong number of products at '" << to_original_string(inst
) << "'\n" << end();
415 for (int i
= 0; i
< SIZE(caller_recipe
.products
); ++i
) {
416 if (!types_match(caller_recipe
.products
.at(i
), inst
.ingredients
.at(i
)))
417 raise
<< maybe(caller_recipe
.name
) << "replied with the wrong type at '" << to_original_string(inst
) << "'\n" << end();
422 void test_recipe_headers_are_checked_2() {
425 "def add2 x:num, y:num [\n"
427 " load-ingredients\n"
428 " z:&:num <- copy 0/unsafe\n"
432 CHECK_TRACE_CONTENTS(
433 "error: add2: replied with the wrong number of products at 'return z'\n"
437 void test_recipe_headers_are_checked_against_pre_transformed_instructions() {
440 "def foo -> x:num [\n"
443 " z:bool <- copy false\n"
447 CHECK_TRACE_CONTENTS(
448 "error: foo: replied with the wrong type at 'return-if z, z'\n"
452 void test_recipe_headers_check_for_duplicate_names() {
455 "def foo x:num, x:num -> z:num [\n"
457 " load-ingredients\n"
461 CHECK_TRACE_CONTENTS(
462 "error: foo: 'x' can't repeat in the ingredients\n"
466 void test_recipe_headers_check_for_duplicate_names_2() {
469 "def foo x:num, x:num [ # no result\n"
471 " load-ingredients\n"
474 CHECK_TRACE_CONTENTS(
475 "error: foo: 'x' can't repeat in the ingredients\n"
479 void test_recipe_headers_check_for_missing_types() {
485 "def foo a [\n" // no type for 'a'
488 CHECK_TRACE_CONTENTS(
489 "error: foo: ingredient 'a' has no type\n"
493 :(before
"End recipe Fields")
494 map
<string
, int> ingredient_index
;
496 :(after
"Begin Instruction Modifying Transforms")
497 Transform
.push_back(check_header_ingredients
); // idempotent
500 void check_header_ingredients(const recipe_ordinal r
) {
501 recipe
& caller_recipe
= get(Recipe
, r
);
502 caller_recipe
.ingredient_index
.clear();
503 trace(101, "transform") << "--- checking return instructions against header for " << caller_recipe
.name
<< end();
504 for (int i
= 0; i
< SIZE(caller_recipe
.ingredients
); ++i
) {
505 if (caller_recipe
.ingredients
.at(i
).type
== NULL
)
506 raise
<< maybe(caller_recipe
.name
) << "ingredient '" << caller_recipe
.ingredients
.at(i
).name
<< "' has no type\n" << end();
507 if (contains_key(caller_recipe
.ingredient_index
, caller_recipe
.ingredients
.at(i
).name
))
508 raise
<< maybe(caller_recipe
.name
) << "'" << caller_recipe
.ingredients
.at(i
).name
<< "' can't repeat in the ingredients\n" << end();
509 put(caller_recipe
.ingredient_index
, caller_recipe
.ingredients
.at(i
).name
, i
);
513 //: Deduce types from the header if possible.
515 void test_deduce_instruction_types_from_recipe_header() {
518 " 1:num/raw <- add2 3, 5\n"
520 "def add2 x:num, y:num -> z:num [\n"
522 " load-ingredients\n"
523 " z <- add x, y # no type for z\n"
527 CHECK_TRACE_CONTENTS(
528 "mem: storing 8 in location 1\n"
532 :(after
"Begin Type Modifying Transforms")
533 Transform
.push_back(deduce_types_from_header
); // idempotent
536 void deduce_types_from_header(const recipe_ordinal r
) {
537 recipe
& caller_recipe
= get(Recipe
, r
);
538 if (caller_recipe
.products
.empty()) return;
539 trace(101, "transform") << "--- deduce types from header for " << caller_recipe
.name
<< end();
540 map
<string
, const type_tree
*> header_type
;
541 for (int i
= 0; i
< SIZE(caller_recipe
.ingredients
); ++i
) {
542 if (!caller_recipe
.ingredients
.at(i
).type
) continue; // error handled elsewhere
543 put(header_type
, caller_recipe
.ingredients
.at(i
).name
, caller_recipe
.ingredients
.at(i
).type
);
544 trace(103, "transform") << "type of " << caller_recipe
.ingredients
.at(i
).name
<< " is " << names_to_string(caller_recipe
.ingredients
.at(i
).type
) << end();
546 for (int i
= 0; i
< SIZE(caller_recipe
.products
); ++i
) {
547 if (!caller_recipe
.products
.at(i
).type
) continue; // error handled elsewhere
548 put(header_type
, caller_recipe
.products
.at(i
).name
, caller_recipe
.products
.at(i
).type
);
549 trace(103, "transform") << "type of " << caller_recipe
.products
.at(i
).name
<< " is " << names_to_string(caller_recipe
.products
.at(i
).type
) << end();
551 for (int i
= 0; i
< SIZE(caller_recipe
.steps
); ++i
) {
552 instruction
& inst
= caller_recipe
.steps
.at(i
);
553 trace(102, "transform") << "instruction: " << to_string(inst
) << end();
554 for (int i
= 0; i
< SIZE(inst
.ingredients
); ++i
) {
555 if (inst
.ingredients
.at(i
).type
) continue;
556 if (header_type
.find(inst
.ingredients
.at(i
).name
) == header_type
.end())
558 if (!contains_key(header_type
, inst
.ingredients
.at(i
).name
)) continue; // error handled elsewhere
559 inst
.ingredients
.at(i
).type
= new type_tree(*get(header_type
, inst
.ingredients
.at(i
).name
));
560 trace(103, "transform") << "type of " << inst
.ingredients
.at(i
).name
<< " is " << names_to_string(inst
.ingredients
.at(i
).type
) << end();
562 for (int i
= 0; i
< SIZE(inst
.products
); ++i
) {
563 trace(103, "transform") << " product: " << to_string(inst
.products
.at(i
)) << end();
564 if (inst
.products
.at(i
).type
) continue;
565 if (header_type
.find(inst
.products
.at(i
).name
) == header_type
.end())
567 if (!contains_key(header_type
, inst
.products
.at(i
).name
)) continue; // error handled elsewhere
568 inst
.products
.at(i
).type
= new type_tree(*get(header_type
, inst
.products
.at(i
).name
));
569 trace(103, "transform") << "type of " << inst
.products
.at(i
).name
<< " is " << names_to_string(inst
.products
.at(i
).type
) << end();
574 //: One final convenience: no need to say what to return if the information is
577 void test_return_based_on_header() {
580 " 1:num/raw <- add2 3, 5\n"
582 "def add2 x:num, y:num -> z:num [\n"
584 " load-ingredients\n"
589 CHECK_TRACE_CONTENTS(
590 "mem: storing 8 in location 1\n"
594 :(after
"Transform.push_back(check_header_ingredients)")
595 Transform
.push_back(fill_in_return_ingredients
); // idempotent
598 void fill_in_return_ingredients(const recipe_ordinal r
) {
599 recipe
& caller_recipe
= get(Recipe
, r
);
600 trace(101, "transform") << "--- fill in return ingredients from header for recipe " << caller_recipe
.name
<< end();
601 if (!caller_recipe
.has_header
) return;
602 for (int i
= 0; i
< SIZE(caller_recipe
.steps
); ++i
) {
603 instruction
& inst
= caller_recipe
.steps
.at(i
);
604 if (inst
.name
== "reply" || inst
.name
== "return")
605 add_header_products(inst
, caller_recipe
);
607 // fall through return
608 if (!caller_recipe
.steps
.empty()) {
609 const instruction
& final_instruction
= caller_recipe
.steps
.at(SIZE(caller_recipe
.steps
)-1);
610 if (final_instruction
.name
== "reply" || final_instruction
.name
== "return")
614 inst
.name
= "return";
615 add_header_products(inst
, caller_recipe
);
616 caller_recipe
.steps
.push_back(inst
);
619 void add_header_products(instruction
& inst
, const recipe
& caller_recipe
) {
620 assert(inst
.name
== "reply" || inst
.name
== "return");
621 // collect any products with the same names as ingredients
622 for (int i
= 0; i
< SIZE(caller_recipe
.products
); ++i
) {
623 // if the ingredient is missing, add it from the header
624 if (SIZE(inst
.ingredients
) == i
)
625 inst
.ingredients
.push_back(caller_recipe
.products
.at(i
));
626 // if it's missing /same_as_ingredient, try to fill it in
627 if (contains_key(caller_recipe
.ingredient_index
, caller_recipe
.products
.at(i
).name
) && !has_property(inst
.ingredients
.at(i
), "same_as_ingredient")) {
628 ostringstream same_as_ingredient
;
629 same_as_ingredient
<< get(caller_recipe
.ingredient_index
, caller_recipe
.products
.at(i
).name
);
630 inst
.ingredients
.at(i
).properties
.push_back(pair
<string
, string_tree
*>("same-as-ingredient", new string_tree(same_as_ingredient
.str())));
635 void test_explicit_return_ignores_header() {
638 " 1:num/raw, 2:num/raw <- add2 3, 5\n"
640 "def add2 a:num, b:num -> y:num, z:num [\n"
642 " load-ingredients\n"
644 " z <- subtract a, b\n"
648 CHECK_TRACE_CONTENTS(
649 "mem: storing 3 in location 1\n"
650 "mem: storing -2 in location 2\n"
654 void test_return_on_fallthrough_based_on_header() {
657 " 1:num/raw <- add2 3, 5\n"
659 "def add2 x:num, y:num -> z:num [\n"
661 " load-ingredients\n"
665 CHECK_TRACE_CONTENTS(
666 "transform: instruction: return {z: \"number\"}\n"
667 "mem: storing 8 in location 1\n"
671 void test_return_on_fallthrough_already_exists() {
674 " 1:num/raw <- add2 3, 5\n"
676 "def add2 x:num, y:num -> z:num [\n"
678 " load-ingredients\n"
679 " z <- add x, y # no type for z\n"
683 CHECK_TRACE_CONTENTS(
684 "transform: instruction: return {z: ()}\n"
686 CHECK_TRACE_DOESNT_CONTAIN("transform: instruction: return z:num");
687 CHECK_TRACE_CONTENTS(
688 "mem: storing 8 in location 1\n"
692 void test_return_causes_error_in_empty_recipe() {
695 "def foo -> x:num [\n"
698 CHECK_TRACE_CONTENTS(
699 "error: foo: tried to read ingredient 'x' in 'return x:num' but it hasn't been written to yet\n"
703 void test_return_after_conditional_return_based_on_header() {
706 " 1:num/raw <- add2 3, 5\n"
708 "def add2 x:num, y:num -> z:num [\n"
710 " load-ingredients\n"
711 " z <- add x, y\n" // no type for z
712 " return-if false, 34\n"
715 CHECK_TRACE_CONTENTS(
716 "mem: storing 8 in location 1\n"
720 void test_recipe_headers_perform_same_ingredient_check() {
724 " 1:num <- copy 34\n"
725 " 2:num <- copy 34\n"
726 " 3:num <- add2 1:num, 2:num\n"
728 "def add2 x:num, y:num -> x:num [\n"
730 " load-ingredients\n"
733 CHECK_TRACE_CONTENTS(
734 "error: main: '3:num <- add2 1:num, 2:num' should write to '1:num' rather than '3:num'\n"
738 //: One special-case is recipe 'main'. Make sure it's only ever taking in text
739 //: ingredients, and returning a single number.
741 void test_recipe_header_ingredients_constrained_for_main() {
747 CHECK_TRACE_CONTENTS(
748 "error: ingredients of recipe 'main' must all be text (address:array:character)\n"
751 void test_recipe_header_products_constrained_for_main() {
754 "def main -> x:text [\n"
757 CHECK_TRACE_CONTENTS(
758 "error: recipe 'main' must return at most a single product, a number\n"
761 void test_recipe_header_products_constrained_for_main_2() {
764 "def main -> x:num, y:num [\n"
767 CHECK_TRACE_CONTENTS(
768 "error: recipe 'main' must return at most a single product, a number\n"
772 :(after
"Transform.push_back(expand_type_abbreviations)")
773 Transform
.push_back(check_recipe_header_constraints
);
775 void check_recipe_header_constraints(const recipe_ordinal r
) {
776 const recipe
& caller
= get(Recipe
, r
);
777 if (caller
.name
!= "main") return;
778 trace(102, "transform") << "check recipe header constraints for recipe " << caller
.name
<< end();
779 if (!caller
.has_header
) return;
780 reagent
/*local*/ expected_ingredient("x:address:array:character");
781 for (int i
= 0; i
< SIZE(caller
.ingredients
); ++i
) {
782 if (!types_strictly_match(expected_ingredient
, caller
.ingredients
.at(i
))) {
783 raise
<< "ingredients of recipe 'main' must all be text (address:array:character)\n" << end();
787 int nprod
= SIZE(caller
.products
);
788 reagent
/*local*/ expected_product("x:number");
790 || (nprod
== 1 && !types_strictly_match(expected_product
, caller
.products
.at(0)))) {
791 raise
<< "recipe 'main' must return at most a single product, a number\n" << end();