about summary refs log tree commit diff stats
path: root/021check_instruction.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-04-15 17:40:12 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-04-15 17:40:12 -0700
commitd785efe59c4b586763728b2a5574cf5fd8574f17 (patch)
tree633f94147f45c544a96828b41005dea791a0e48f /021check_instruction.cc
parentd31d70b60e6f136ad99274051ccbd494c4e6d058 (diff)
downloadmu-d785efe59c4b586763728b2a5574cf5fd8574f17.tar.gz
2836 - arcane bug in generic functions
Thanks Caleb Couch for finding and reporting this.
Diffstat (limited to '021check_instruction.cc')
-rw-r--r--021check_instruction.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc
index 898b3214..138aa733 100644
--- a/021check_instruction.cc
+++ b/021check_instruction.cc
@@ -157,10 +157,23 @@ bool types_strictly_match(reagent to, reagent from) {
 bool types_strictly_match(type_tree* to, type_tree* from) {
   if (!to) return true;
   if (!from) return to->value == 0;
+  if (from->value == -1) return from->name == to->name;
   if (to->value != from->value) return false;
   return types_strictly_match(to->left, from->left) && types_strictly_match(to->right, from->right);
 }
 
+void test_unknown_type_does_not_match_unknown_type() {
+  reagent a("a:foo");
+  reagent b("b:bar");
+  CHECK(!types_strictly_match(a, b));
+}
+
+void test_unknown_type_matches_itself() {
+  reagent a("a:foo");
+  reagent b("b:foo");
+  CHECK(types_strictly_match(a, b));
+}
+
 bool is_unsafe(const reagent& r) {
   return has_property(r, "unsafe");
 }