about summary refs log tree commit diff stats
path: root/011load.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-30 12:03:16 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-30 12:03:16 -0800
commit1cfcb62fa11e2f57fb982500c7df810826988dfc (patch)
tree1f330bc2fc87765438f318e934890848035b1285 /011load.cc
parent2ac236e2bc7b6c392142b296b9f6353ee6d9662e (diff)
downloadmu-1cfcb62fa11e2f57fb982500c7df810826988dfc.tar.gz
2617 - better error messages
When we stash a value, mu does several levels of work for us:

a) First it inserts instructions above the stash to convert the value to
text using to-text-line.
b) to-text-line calls to-text. Both are shape-shifting, so multiple
levels of specialization happen.

To give a good error message, we track the 'stack' of current
specializations at the time of the error, and also check if the
offending instruction at the top-most level looks like it was inserted
while rewriting stash instructions.

Manual example (since booleans can't be stashed at the moment):
  x:boolean <- copy 1/true
  stash x
Diffstat (limited to '011load.cc')
-rw-r--r--011load.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/011load.cc b/011load.cc
index 2c99bfff..dd1f9369 100644
--- a/011load.cc
+++ b/011load.cc
@@ -75,8 +75,10 @@ void slurp_body(istream& in, recipe& result) {
   while (next_instruction(in, &curr)) {
     // End Rewrite Instruction(curr, recipe result)
     trace(9992, "load") << "after rewriting: " << curr.to_string() << end();
-    if (!curr.is_clear())
+    if (!curr.is_clear()) {
+      curr.original_string = curr.to_string();
       result.steps.push_back(curr);
+    }
   }
 }