about summary refs log tree commit diff stats
path: root/022constant.cc
diff options
context:
space:
mode:
Diffstat (limited to '022constant.cc')
-rw-r--r--022constant.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/022constant.cc b/022constant.cc
index 800e1b2b..6fc9a019 100644
--- a/022constant.cc
+++ b/022constant.cc
@@ -3,6 +3,8 @@
 :(before "End Mu Types Initialization")
 put(Type_ordinal, "literal-boolean", 0);
 
+//: 'true'
+
 :(scenario true)
 def main [
   1:boolean <- copy true
@@ -21,6 +23,8 @@ if (name == "true") {
 :(before "End Literal types_match Special-cases")
 if (is_mu_boolean(to)) return from.name == "false" || from.name == "true";
 
+//: 'false'
+
 :(scenario false)
 def main [
   1:boolean <- copy false
@@ -36,3 +40,50 @@ if (name == "false") {
   type = new type_tree("literal-boolean");
   set_value(0);
 }
+
+//: 'null'
+
+:(scenario null)
+def main [
+  1:address:number <- copy null
+]
++mem: storing 0 in location 1
+
+:(scenario null_has_wildcard_type)
+def main [
+  1:address:boolean <- copy null
+]
++mem: storing 0 in location 1
+
+:(before "End Mu Types Initialization")
+put(Type_ordinal, "literal-address", 0);
+
+:(before "End Parsing reagent")
+if (name == "null") {
+  if (type != NULL) {
+    raise << "'null' is a literal and can't take a type\n" << end();
+    return;
+  }
+  type = new type_tree("literal-address");
+  set_value(0);
+}
+
+:(before "End Literal->Address types_match(from) Special-cases")
+// allow writing null to any address
+if (from.name == "null") return true;
+
+//: scenarios for type abbreviations that we couldn't write until now
+
+:(scenario type_abbreviation_for_compound)
+type foo = address:number
+def main [
+  1:foo <- copy null
+]
++transform: product type after expanding abbreviations: ("address" "number")
+
+:(scenario use_type_abbreviations_when_declaring_type_abbreviations)
+type foo = &:num
+def main [
+  1:foo <- copy null
+]
++transform: product type after expanding abbreviations: ("address" "number")