about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-24 01:03:55 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-24 01:03:55 -0700
commit7a8db77002a2ab90c923dffac18128defe47c177 (patch)
treefbc47f85834dfa31809bdc63e12c90635ac5c127
parent0b1d1b202667f69de44fe989b3838c06a4a42619 (diff)
downloadmu-7a8db77002a2ab90c923dffac18128defe47c177.tar.gz
1832
-rw-r--r--030container.cc5
-rw-r--r--042name.cc2
-rw-r--r--043new.cc2
-rw-r--r--edit.mu32
4 files changed, 38 insertions, 3 deletions
diff --git a/030container.cc b/030container.cc
index c49aa877..2263833c 100644
--- a/030container.cc
+++ b/030container.cc
@@ -111,7 +111,10 @@ case GET: {
     raise << current_recipe_name () << ": 'get' on a non-container " << base.original_string << '\n';
     break;
   }
-  assert(is_literal(current_instruction().ingredients.at(1)));
+  if (!is_literal(current_instruction().ingredients.at(1))) {
+    raise << current_recipe_name() << ": expected ingredient 1 of 'get' to have type 'offset', got '" << current_instruction().ingredients.at(1).original_string << "'\n";
+    break;
+  }
   assert(scalar(ingredients.at(1)));
   long long int offset = ingredients.at(1).at(0);
   long long int src = base_address;
diff --git a/042name.cc b/042name.cc
index fe3c43a7..ed322d54 100644
--- a/042name.cc
+++ b/042name.cc
@@ -223,7 +223,7 @@ if (inst.operation == Recipe_ordinal["get"]
   assert(SIZE(inst.ingredients) >= 2);
 //?   cout << inst.ingredients.at(1).to_string() << '\n'; //? 1
   if (!is_literal(inst.ingredients.at(1)))
-    raise << inst.to_string() << ": expected literal; got " << inst.ingredients.at(1).to_string() << '\n' << die();
+    raise << Recipe[r].name << ": expected ingredient 1 of " << (inst.operation == Recipe_ordinal["get"] ? "'get'" : "'get-address'") << " to have type 'offset'; got " << inst.ingredients.at(1).original_string << '\n' << die();
   if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) {
     // since first non-address in base type must be a container, we don't have to canonize
     type_ordinal base_type = skip_addresses(inst.ingredients.at(0).types);
diff --git a/043new.cc b/043new.cc
index 39c3aff4..672b4bb1 100644
--- a/043new.cc
+++ b/043new.cc
@@ -36,7 +36,7 @@ if (inst.operation == Recipe_ordinal["new"]) {
   // first arg must be of type 'type'
   assert(SIZE(inst.ingredients) >= 1);
   if (!is_literal(inst.ingredients.at(0)))
-    raise << "expected literal, got " << inst.ingredients.at(0).to_string() << '\n' << die();
+    raise << "expected literal, got " << inst.ingredients.at(0).original_string << '\n' << die();
   if (inst.ingredients.at(0).properties.at(0).second.at(0) != "type")
     raise << "tried to allocate non-type " << inst.ingredients.at(0).to_string() << " in recipe " << Recipe[r].name << '\n' << die();
   if (Type_ordinal.find(inst.ingredients.at(0).name) == Type_ordinal.end())
diff --git a/edit.mu b/edit.mu
index 9b63afe4..c50ec135 100644
--- a/edit.mu
+++ b/edit.mu
@@ -3260,6 +3260,38 @@ recipe foo [
   ]
 ]
 
+scenario run-shows-non-literal-get-argument-warnings [
+  $close-trace
+  assume-screen 100:literal/width, 15:literal/height
+  assume-console [
+    press 65526  # F10
+  ]
+  run [
+    x:address:array:character <- new [ 
+recipe foo [
+  x:number <- copy 0
+  y:address:point <- new point:type
+  get y:address:point/deref, x:number
+]]
+    y:address:array:character <- new [foo]
+    env:address:programming-environment-data <- new-programming-environment screen:address, x:address:array:character, y:address:array:character
+    event-loop screen:address, console:address, env:address:programming-environment-data
+  ]
+  screen-should-contain [
+    .                                                                                 run (F10)          .
+    .                                                  ┊                                                 .
+    .recipe foo [                                      ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .  x:number <- copy 0                              ┊                                                x.
+    .  y:address:point <- new point:type               ┊foo                                              .
+    .  get y:address:point/deref, x:number             ┊foo: expected ingredient 1 of 'get' to have type↩.
+    .]                                                 ┊ 'offset', got 'x:number'                        .
+    .foo: expected ingredient 1 of 'get' to have type ↩┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
+    .'offset'; got x:number                            ┊                                                 .
+    .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
+    .                                                  ┊                                                 .
+  ]
+]
+
 ## helpers for drawing editor borders
 
 recipe draw-box [