about summary refs log tree commit diff stats
path: root/064random.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-25 14:19:28 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-25 17:14:58 -0700
commite46306432ddb75a89f69d92ccc175a23f0b72072 (patch)
tree48ed3828064f29cefaf14e3fe61d7dc02cac0e80 /064random.cc
parente83602d3917eba137cd8fb37605076fff5a746b1 (diff)
downloadmu-e46306432ddb75a89f69d92ccc175a23f0b72072.tar.gz
1848 - core instructions now check for ingredients
Also standardized warnings.
Diffstat (limited to '064random.cc')
-rw-r--r--064random.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/064random.cc b/064random.cc
index 6fadeb40..bd171132 100644
--- a/064random.cc
+++ b/064random.cc
@@ -27,7 +27,14 @@ ROUND,
 Recipe_ordinal["round"] = ROUND;
 :(before "End Primitive Recipe Implementations")
 case ROUND: {
-  assert(scalar(ingredients.at(0)));
+  if (SIZE(ingredients) != 1) {
+    raise << current_recipe_name() << ": 'round' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
+    break;
+  }
+  if (!scalar(ingredients.at(0))) {
+    raise << current_recipe_name() << ": first ingredient of 'round' should be a number, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+    break;
+  }
   products.resize(1);
   products.at(0).push_back(rint(ingredients.at(0).at(0)));
   break;