about summary refs log tree commit diff stats
path: root/053recipe_header.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-23 22:07:14 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-23 22:07:14 -0700
commit61880904a2f1446f331ac48ad56b3e7c006d0d55 (patch)
treed1e1581d39ea4e1751cd36a5cb3d90338dca1af6 /053recipe_header.cc
parent7f707a515eb26c4bcd4168412a0a1c65a81b1e05 (diff)
downloadmu-61880904a2f1446f331ac48ad56b3e7c006d0d55.tar.gz
3576
More helpful messages when people forget 'load-ingredients'.
Diffstat (limited to '053recipe_header.cc')
-rw-r--r--053recipe_header.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/053recipe_header.cc b/053recipe_header.cc
index fc6312b4..e6cc51d9 100644
--- a/053recipe_header.cc
+++ b/053recipe_header.cc
@@ -220,6 +220,34 @@ case NEXT_INGREDIENT_WITHOUT_TYPECHECKING: {
   break;
 }
 
+//: more useful error messages if someone forgets 'load-ingredients'
+
+:(scenario load_ingredients_missing_error)
+% Hide_errors = true;
+def foo a:num [
+  local-scope
+  b:num <- add a:num, 1
+]
++error: foo: use before set: 'a'
++error:   did you forget 'load-ingredients'?
+
+:(after "use-before-set Error")
+if (is_present_in_ingredients(caller, ingredient.name))
+  raise << "  did you forget 'load-ingredients'?\n" << end();
+
+:(scenario load_ingredients_missing_error_2)
+% Hide_errors = true;
+def foo a:num [
+  local-scope
+  b:num <- add a, 1
+]
++error: foo: missing type for 'a' in 'b:num <- add a, 1'
++error:   did you forget 'load-ingredients'?
+
+:(after "missing-type Error 1")
+if (is_present_in_ingredients(get(Recipe, get(Recipe_ordinal, recipe_name)), x.name))
+  raise << "  did you forget 'load-ingredients'?\n" << end();
+
 //:: Check all calls against headers.
 
 :(scenario show_clear_error_on_bad_call)