changeset 221:218b11ec8fa2

Better handling for weird values being inserted into AST due to quoting
author Michael Pavone <pavone@retrodev.com>
date Sun, 29 Dec 2013 13:07:10 -0800
parents a1a80af71b05
children c6e321a538d4
files interp.js
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/interp.js	Mon Dec 23 14:44:31 2013 -0800
+++ b/interp.js	Sun Dec 29 13:07:10 2013 -0800
@@ -230,7 +230,10 @@
 	if (val == tpfalse) {
 		return new symbol('false');
 	}
-	return val;
+	if ('makeHygienic' in val) {
+		return val;
+	}
+	return null;
 }
 
 op.prototype.eval = function(env) {
@@ -306,6 +309,9 @@
 	var val = env.find(this.name);
 	if (val !== null) {
 		var newnode = makeASTNode(val);
+		if (!newnode) {
+			throw new Error(this.name + ' contains a value ' + val + ' that could not be converted to an AST node');
+		}
 		return newnode;
 	} else {
 		this.dirty = true;
@@ -836,7 +842,7 @@
 	if (val) {
 		var node = makeASTNode(val);
 		if (!(node instanceof symbol)) {
-			throw new Error('Left hand side of assignment expression must be a symbol!');
+			throw new Error('Left hand side of assignment expression must be a symbol not a '+ node.constructor.name + ' '+(typeof node) + ', old name was ' + name);
 		}
 		name = node.cleanName();
 		dirty = node.dirty;