about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-25 07:39:25 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-25 07:46:56 -0800
commitf51e9f63b40ce3d5c4d40808bf1b7e83ab7d60ff (patch)
tree4730fc0e0e69e8537686730a7a233d84b54f0266
parentb5ab709c53d3f8464e6358678a3c57a1fc6e64b8 (diff)
downloadmu-f51e9f63b40ce3d5c4d40808bf1b7e83ab7d60ff.tar.gz
2701 - turn some warnings into errors
I really have only one warning left: when somebody redefines a function.
I think I'm going to just turn that into an error as well and drop the
notion of warnings altogether. Anytime we find something wrong we stop
running the program. This is a place where hygiene is justified.
-rw-r--r--037new.cc4
-rw-r--r--040brace.cc2
-rw-r--r--043space.cc2
-rw-r--r--045closure_name.cc2
-rw-r--r--056recipe_header.cc12
-rw-r--r--060immutable.cc50
-rw-r--r--077hash.cc2
7 files changed, 37 insertions, 37 deletions
diff --git a/037new.cc b/037new.cc
index d88fc8fc..950e7e37 100644
--- a/037new.cc
+++ b/037new.cc
@@ -187,14 +187,14 @@ case ALLOCATE: {
 //:: ensure we never call 'allocate' directly; its types are not checked
 :(before "End Primitive Recipe Checks")
 case ALLOCATE: {
-  raise << "never call 'allocate' directly'; always use 'new'\n" << end();
+  raise_error << "never call 'allocate' directly'; always use 'new'\n" << end();
   break;
 }
 
 //:: ensure we never call 'new' without translating it (unless we add special-cases later)
 :(before "End Primitive Recipe Implementations")
 case NEW: {
-  raise << "no implementation for 'new'; why wasn't it translated to 'allocate'?\n" << end();
+  raise_error << "no implementation for 'new'; why wasn't it translated to 'allocate'? Please save a copy of your program and send it to Kartik.\n" << end();
   break;
 }
 
diff --git a/040brace.cc b/040brace.cc
index 735cdab3..5d9dc189 100644
--- a/040brace.cc
+++ b/040brace.cc
@@ -61,7 +61,7 @@ void transform_braces(const recipe_ordinal r) {
     }
     if (inst.label == "}") {
       if (open_braces.empty()) {
-        raise << "missing '{' in " << get(Recipe, r).name << '\n' << end();
+        raise_error << "missing '{' in " << get(Recipe, r).name << '\n' << end();
         return;
       }
       open_braces.pop();
diff --git a/043space.cc b/043space.cc
index fdd987b2..a1c91a34 100644
--- a/043space.cc
+++ b/043space.cc
@@ -264,7 +264,7 @@ void check_default_space(const recipe_ordinal r) {
   if (caller.steps.empty()) return;
   if (caller.steps.at(0).products.empty()
       || caller.steps.at(0).products.at(0).name != "default-space") {
-    raise << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << end();
+    raise_error << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << end();
 //?     cerr << maybe(caller.name) << " does not seem to start with default-space or local-scope\n" << '\n';
   }
 }
diff --git a/045closure_name.cc b/045closure_name.cc
index cb258583..701c69fa 100644
--- a/045closure_name.cc
+++ b/045closure_name.cc
@@ -80,7 +80,7 @@ void collect_surrounding_spaces(const recipe_ordinal r) {
       trace(9993, "name") << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << end();
 //?       cerr << "lexically surrounding space for recipe " << get(Recipe, r).name << " comes from " << surrounding_recipe_name << '\n';
       if (!contains_key(Recipe_ordinal, surrounding_recipe_name)) {
-        raise << "can't find recipe providing surrounding space for " << get(Recipe, r).name << ": " << surrounding_recipe_name << '\n' << end();
+        raise_error << "can't find recipe providing surrounding space for " << get(Recipe, r).name << ": " << surrounding_recipe_name << '\n' << end();
         continue;
       }
       put(Surrounding_space, r, get(Recipe_ordinal, surrounding_recipe_name));
diff --git a/056recipe_header.cc b/056recipe_header.cc
index 046a607a..01105e7a 100644
--- a/056recipe_header.cc
+++ b/056recipe_header.cc
@@ -220,7 +220,7 @@ void check_calls_against_header(const recipe_ordinal r) {
       if (!types_coercible(callee.ingredients.at(i), inst.ingredients.at(i)))
         raise_error << maybe(caller.name) << "ingredient " << i << " has the wrong type at '" << to_string(inst) << "'\n" << end();
       if (is_unique_address(inst.ingredients.at(i)))
-        raise << maybe(caller.name) << "try to avoid passing non-shared addresses into calls, like ingredient " << i << " at '" << to_string(inst) << "'\n" << end();
+        raise_error << maybe(caller.name) << "try to avoid passing non-shared addresses into calls, like ingredient " << i << " at '" << to_string(inst) << "'\n" << end();
     }
     for (long int i = 0; i < min(SIZE(inst.products), SIZE(callee.products)); ++i) {
       if (is_dummy(inst.products.at(i))) continue;
@@ -228,7 +228,7 @@ void check_calls_against_header(const recipe_ordinal r) {
       if (!types_coercible(inst.products.at(i), callee.products.at(i)))
         raise_error << maybe(caller.name) << "product " << i << " has the wrong type at '" << to_string(inst) << "'\n" << end();
       if (is_unique_address(inst.products.at(i)))
-        raise << maybe(caller.name) << "try to avoid getting non-shared addresses out of calls, like product " << i << " at '" << to_string(inst) << "'\n" << end();
+        raise_error << maybe(caller.name) << "try to avoid getting non-shared addresses out of calls, like product " << i << " at '" << to_string(inst) << "'\n" << end();
     }
   }
 }
@@ -244,7 +244,7 @@ bool is_unique_address(reagent x) {
 //: additionally, warn on calls receiving non-shared addresses
 
 :(scenario warn_on_calls_with_addresses)
-% Hide_warnings= true;
+% Hide_errors = true;
 recipe main [
   1:address:number <- copy 3/unsafe
   foo 1:address:number
@@ -253,10 +253,10 @@ recipe foo x:address:number [
   local-scope
   load-ingredients
 ]
-+warn: main: try to avoid passing non-shared addresses into calls, like ingredient 0 at 'foo 1:address:number'
++error: main: try to avoid passing non-shared addresses into calls, like ingredient 0 at 'foo 1:address:number'
 
 :(scenario warn_on_calls_with_addresses_2)
-% Hide_warnings= true;
+% Hide_errors = true;
 recipe main [
   1:address:number <- foo
 ]
@@ -265,7 +265,7 @@ recipe foo -> x:address:number [
   load-ingredients
   x <- copy 0
 ]
-+warn: main: try to avoid getting non-shared addresses out of calls, like product 0 at '1:address:number <- foo '
++error: main: try to avoid getting non-shared addresses out of calls, like product 0 at '1:address:number <- foo '
 
 //:: Check types going in and out of all recipes with headers.
 
diff --git a/060immutable.cc b/060immutable.cc
index 67087d28..2ac5d835 100644
--- a/060immutable.cc
+++ b/060immutable.cc
@@ -2,7 +2,7 @@
 //: also products. This layer will start enforcing this check.
 
 :(scenario can_modify_value_ingredients)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   local-scope
   p:address:shared:point <- new point:type
@@ -14,10 +14,10 @@ recipe foo p:point [
   x:address:number <- get-address p, x:offset
   *x <- copy 34
 ]
-$warn: 0
+$error: 0
 
 :(scenario can_modify_ingredients_that_are_also_products)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   local-scope
   p:address:shared:point <- new point:type
@@ -29,10 +29,10 @@ recipe foo p:address:shared:point -> p:address:shared:point [
   x:address:number <- get-address *p, x:offset
   *x <- copy 34
 ]
-$warn: 0
+$error: 0
 
 :(scenario ignore_literal_ingredients_for_immutability_checks)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   local-scope
   p:address:shared:d1 <- new d1:type
@@ -49,10 +49,10 @@ container d1 [
   p:number
   q:number
 ]
-$warn: 0
+$error: 0
 
 :(scenario cannot_take_address_inside_immutable_ingredients)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   local-scope
   p:address:shared:point <- new point:type
@@ -64,10 +64,10 @@ recipe foo p:address:shared:point [
   x:address:number <- get-address *p, x:offset
   *x <- copy 34
 ]
-+warn: foo: cannot modify ingredient p after instruction 'x:address:number <- get-address *p, x:offset' because it's not also a product of foo
++error: foo: cannot modify ingredient p after instruction 'x:address:number <- get-address *p, x:offset' because it's not also a product of foo
 
 :(scenario cannot_call_mutating_recipes_on_immutable_ingredients)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   local-scope
   p:address:shared:point <- new point:type
@@ -84,10 +84,10 @@ recipe bar p:address:shared:point -> p:address:shared:point [
   x:address:number <- get-address *p, x:offset
   *x <- copy 34
 ]
-+warn: foo: cannot modify ingredient p at instruction 'bar p' because it's not also a product of foo
++error: foo: cannot modify ingredient p at instruction 'bar p' because it's not also a product of foo
 
 :(scenario cannot_modify_copies_of_immutable_ingredients)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   local-scope
   p:address:shared:point <- new point:type
@@ -99,10 +99,10 @@ recipe foo p:address:shared:point [
   q:address:shared:point <- copy p
   x:address:number <- get-address *q, x:offset
 ]
-+warn: foo: cannot modify q after instruction 'x:address:number <- get-address *q, x:offset' because that would modify ingredient p which is not also a product of foo
++error: foo: cannot modify q after instruction 'x:address:number <- get-address *q, x:offset' because that would modify ingredient p which is not also a product of foo
 
 :(scenario can_traverse_immutable_ingredients)
-% Hide_warnings = true;
+% Hide_errors = true;
 container test-list [
   next:address:shared:test-list
 ]
@@ -121,10 +121,10 @@ recipe bar x:address:shared:test-list -> y:address:shared:test-list [
   load-ingredients
   y <- get *x, next:offset
 ]
-$warn: 0
+$error: 0
 
 :(scenario handle_optional_ingredients_in_immutability_checks)
-% Hide_warnings = true;
+% Hide_errors = true;
 recipe main [
   k:address:shared:number <- new number:type
   test k
@@ -141,7 +141,7 @@ recipe foo -> [
   load-ingredients
   k:address:shared:number, found?:boolean <- next-ingredient
 ]
-$warn: 0
+$error: 0
 
 :(before "End Transforms")
 Transform.push_back(check_immutable_ingredients);  // idempotent
@@ -208,7 +208,7 @@ set<long long int> scan_contained_in_product_indices(const instruction& inst, se
 
 :(scenarios transform)
 :(scenario immutability_infects_contained_in_variables)
-% Hide_warnings = true;
+% Hide_errors = true;
 container test-list [
   next:address:shared:test-list
 ]
@@ -228,7 +228,7 @@ recipe test-next x:address:shared:test-list -> y:address:shared:test-list/contai
   load-ingredients
   y <- get *x, next:offset
 ]
-+warn: foo: cannot modify p2 after instruction 'p3:address:address:shared:test-list <- get-address *p2, next:offset' because that would modify ingredient p which is not also a product of foo
++error: foo: cannot modify p2 after instruction 'p3:address:address:shared:test-list <- get-address *p2, next:offset' because that would modify ingredient p which is not also a product of foo
 
 :(code)
 void check_immutable_ingredient_in_instruction(const instruction& inst, const set<string>& current_ingredient_and_aliases, const string& original_ingredient_name, const recipe& caller) {
@@ -243,9 +243,9 @@ void check_immutable_ingredient_in_instruction(const instruction& inst, const se
       // primitive recipe
       if (inst.operation == GET_ADDRESS || inst.operation == INDEX_ADDRESS) {
         if (current_ingredient_name == original_ingredient_name)
-          raise << maybe(caller.name) << "cannot modify ingredient " << current_ingredient_name << " after instruction '" << to_string(inst) << "' because it's not also a product of " << caller.name << '\n' << end();
+          raise_error << maybe(caller.name) << "cannot modify ingredient " << current_ingredient_name << " after instruction '" << to_string(inst) << "' because it's not also a product of " << caller.name << '\n' << end();
         else
-          raise << maybe(caller.name) << "cannot modify " << current_ingredient_name << " after instruction '" << to_string(inst) << "' because that would modify ingredient " << original_ingredient_name << " which is not also a product of " << caller.name << '\n' << end();
+          raise_error << maybe(caller.name) << "cannot modify " << current_ingredient_name << " after instruction '" << to_string(inst) << "' because that would modify ingredient " << original_ingredient_name << " which is not also a product of " << caller.name << '\n' << end();
       }
     }
     else {
@@ -253,9 +253,9 @@ void check_immutable_ingredient_in_instruction(const instruction& inst, const se
       if (!is_mu_address(current_ingredient)) return;  // making a copy is ok
       if (is_modified_in_recipe(inst.operation, current_ingredient_index, caller)) {
         if (current_ingredient_name == original_ingredient_name)
-          raise << maybe(caller.name) << "cannot modify ingredient " << current_ingredient_name << " at instruction '" << to_string(inst) << "' because it's not also a product of " << caller.name << '\n' << end();
+          raise_error << maybe(caller.name) << "cannot modify ingredient " << current_ingredient_name << " at instruction '" << to_string(inst) << "' because it's not also a product of " << caller.name << '\n' << end();
         else
-          raise << maybe(caller.name) << "cannot modify " << current_ingredient_name << " after instruction '" << to_string(inst) << "' because that would modify ingredient " << original_ingredient_name << " which is not also a product of " << caller.name << '\n' << end();
+          raise_error << maybe(caller.name) << "cannot modify " << current_ingredient_name << " after instruction '" << to_string(inst) << "' because that would modify ingredient " << original_ingredient_name << " which is not also a product of " << caller.name << '\n' << end();
       }
     }
   }
@@ -264,7 +264,7 @@ void check_immutable_ingredient_in_instruction(const instruction& inst, const se
 bool is_modified_in_recipe(recipe_ordinal r, long long int ingredient_index, const recipe& caller) {
   const recipe& callee = get(Recipe, r);
   if (!callee.has_header) {
-    raise << maybe(caller.name) << "can't check mutability of ingredients in " << callee.name << " because it uses 'next-ingredient' directly, rather than a recipe header.\n" << end();
+    raise_error << maybe(caller.name) << "can't check mutability of ingredients in " << callee.name << " because it uses 'next-ingredient' directly, rather than a recipe header.\n" << end();
     return true;
   }
   if (ingredient_index >= SIZE(callee.ingredients)) return false;  // optional immutable ingredient
@@ -310,7 +310,7 @@ set<long long int> ingredient_indices(const instruction& inst, const set<string>
 
 :(scenarios transform)
 :(scenario can_modify_contained_in_addresses)
-% Hide_warnings = true;
+% Hide_errors = true;
 container test-list [
   next:address:shared:test-list
 ]
@@ -335,7 +335,7 @@ recipe test-remove x:address:shared:test-list/contained-in:from, from:address:sh
   load-ingredients
   x2:address:address:shared:test-list <- get-address *x, next:offset  # pretend modification
 ]
-$warn: 0
+$error: 0
 
 :(before "End Immutable Ingredients Special-cases")
 if (has_property(current_ingredient, "contained-in")) {
diff --git a/077hash.cc b/077hash.cc
index d483b235..fc98fd3e 100644
--- a/077hash.cc
+++ b/077hash.cc
@@ -122,7 +122,7 @@ size_t hash_mu_exclusive_container(size_t h, const reagent& r) {
   reagent variant = variant_type(r, tag);
   // todo: move this warning to container definition time
   if (has_property(variant, "ignore-for-hash"))
-    raise << get(Type, r.type->value).name << ": /ignore-for-hash won't work in exclusive containers\n" << end();
+    raise_error << get(Type, r.type->value).name << ": /ignore-for-hash won't work in exclusive containers\n" << end();
   variant.set_value(r.value + /*skip tag*/1);
   h = hash(h, variant);
   return h;