about summary refs log tree commit diff stats
path: root/021check_instruction.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-06-17 00:05:38 -0700
committerKartik Agaram <vc@akkartik.com>2018-06-17 00:29:22 -0700
commitdd66068298b0a11f2a1f195376cba98e0c8570b5 (patch)
tree06696728fd65cdf38a2ac571943e130e9d60c333 /021check_instruction.cc
parentb89b822439f47a490a1b764e14a1ed1b73059cba (diff)
downloadmu-dd66068298b0a11f2a1f195376cba98e0c8570b5.tar.gz
4261 - start using literals for 'true' and 'false'
They uncovered one bug: in edit/003-shortcuts.mu
  <scroll-down> was returning 0 for an address in one place where I
  thought it was returning 0 for a boolean.

Now we've eliminated this bad interaction between tangling and punning
literals.
Diffstat (limited to '021check_instruction.cc')
-rw-r--r--021check_instruction.cc19
1 files changed, 1 insertions, 18 deletions
diff --git a/021check_instruction.cc b/021check_instruction.cc
index 44f08f3f..48f90078 100644
--- a/021check_instruction.cc
+++ b/021check_instruction.cc
@@ -86,27 +86,10 @@ def main [
 ]
 $error: 0
 
-:(scenario write_boolean_to_number_allowed)
-def main [
-  1:bool <- copy 1/true
-  2:num <- copy 1:bool
-]
-+mem: storing 1 in location 2
-$error: 0
-
-:(scenario write_number_to_boolean_disallowed)
-% Hide_errors = true;
-def main [
-  1:num <- copy 34
-  2:bool <- copy 1:num
-]
-+error: main: can't copy '1:num' to '2:bool'; types don't match
-
 :(code)
 // types_match with some leniency
 bool types_coercible(const reagent& to, const reagent& from) {
   if (types_match(to, from)) return true;
-  if (is_mu_boolean(from) && is_real_mu_number(to)) return true;
   if (is_real_mu_number(from) && is_mu_character(to)) return true;
   // End types_coercible Special-cases
   return false;
@@ -122,7 +105,7 @@ bool types_match(const reagent& to, const reagent& from) {
     // allow writing 0 to any address
     if (is_mu_address(to)) return from.name == "0";
     if (!to.type) return false;
-    if (is_mu_boolean(to)) return from.name == "0" || from.name == "1";
+    // End Literal types_match Special-cases
     return size_of(to) == 1;  // literals are always scalars
   }
   return types_strictly_match(to, from);