about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-05-05 09:50:20 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-05-05 09:50:23 -0700
commit036566cee9de0a1f2d99e600619e5f8aa4fe3cf0 (patch)
tree85062e464fe1781968a91c2482a2f681bc79be7a
parentc2f7df5fe5b1167200ed53b661f2fbe4b1470ad4 (diff)
downloadmu-036566cee9de0a1f2d99e600619e5f8aa4fe3cf0.tar.gz
2925
Thanks Caleb Couch for showing the need for this check.
-rw-r--r--025compare.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/025compare.cc b/025compare.cc
index 39baa232..c80fcc85 100644
--- a/025compare.cc
+++ b/025compare.cc
@@ -10,6 +10,13 @@ case EQUAL: {
     raise << maybe(get(Recipe, r).name) << "'equal' needs at least two ingredients to compare in '" << to_original_string(inst) << "'\n" << end();
     break;
   }
+  const reagent& exemplar = inst.ingredients.at(0);
+  for (int i = /*skip exemplar*/1; i < SIZE(inst.ingredients); ++i) {
+    if (!types_match(inst.ingredients.at(i), exemplar) && !types_match(exemplar, inst.ingredients.at(i))) {
+      raise << maybe(get(Recipe, r).name) << "'equal' expects ingredients to be all of the same type, but got '" << to_original_string(inst) << "'\n" << end();
+      goto finish_checking_instruction;
+    }
+  }
   if (SIZE(inst.products) > 1) {
     raise << maybe(get(Recipe, r).name) << "'equal' yields exactly one product in '" << to_original_string(inst) << "'\n" << end();
     break;
@@ -24,7 +31,7 @@ case EQUAL: {
 case EQUAL: {
   vector<double>& exemplar = ingredients.at(0);
   bool result = true;
-  for (int i = 1; i < SIZE(ingredients); ++i) {
+  for (int i = /*skip exemplar*/1; i < SIZE(ingredients); ++i) {
     if (!equal(ingredients.at(i).begin(), ingredients.at(i).end(), exemplar.begin())) {
       result = false;
       break;
lt' href='/ahoang/chawan/commit/adapter/finger/cha-finger?id=2dec7483045c9e5696182db7b4ad842491b6c2b2'>2dec7483 ^
2dec7483 ^
d67caf71 ^
2dec7483 ^
5efdc54d ^
d67caf71 ^
f054f85b ^
d67caf71 ^

5efdc54d ^







f054f85b ^
d67caf71 ^




2dec7483 ^
5efdc54d ^

2dec7483 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45