about summary refs log tree commit diff stats
path: root/021check_instruction.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-27 18:10:15 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-27 18:10:15 -0800
commit7f193a0e006c44604918b54c853bd49508dbe8fd (patch)
treea937f880fa2e7a64666c8ceb262dc16de9f777be /021check_instruction.cc
parent0ddcab7bc0e856dfe5e0556e972f3c21fd16d6d1 (diff)
downloadmu-7f193a0e006c44604918b54c853bd49508dbe8fd.tar.gz
2482 - better choice between valid variants
Literal '0' ingredients should map to numbers before addresses.
Diffstat (limited to '021check_instruction.cc')
-rw-r--r--021check_instruction.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc
index f79ae140..930eacde 100644
--- a/021check_instruction.cc
+++ b/021check_instruction.cc
@@ -82,15 +82,19 @@ recipe main [
 $error: 0
 
 :(code)
+bool types_match(const reagent& lhs, const reagent& rhs) {
+  if (!is_unsafe(rhs) && is_literal(rhs)) return valid_type_for_literal(lhs, rhs) && size_of(rhs) == size_of(lhs);
+  return types_strictly_match(lhs, rhs);
+}
+
 // copy arguments because later layers will want to make changes to them
 // without perturbing the caller
-bool types_match(reagent lhs, reagent rhs) {
+bool types_strictly_match(reagent lhs, reagent rhs) {
   // '_' never raises type error
   if (is_dummy(lhs)) return true;
   // to sidestep type-checking, use /unsafe in the source.
   // this will be highlighted in red inside vim. just for setting up some tests.
   if (is_unsafe(rhs)) return true;
-  if (is_literal(rhs)) return valid_type_for_literal(lhs, rhs) && size_of(rhs) == size_of(lhs);
   if (!lhs.type) return !rhs.type;
   return types_match(lhs.type, rhs.type);
 }