# HG changeset patch # User Michael Pavone # Date 1405996223 25200 # Node ID 23b52d2d05a0f214c1e32e074c3ffd4df9381a68 # Parent eb83863fd33ec404e3019e00a7a86b4a298857b3 Don't try to replace self in a macro expansion since it's unlikely to be the desired behavior. A more explicit means of specifying what variables should be replaced in a quote expression is needed. diff -r eb83863fd33e -r 23b52d2d05a0 interp.js --- a/interp.js Mon Jul 21 19:11:15 2014 -0700 +++ b/interp.js Mon Jul 21 19:30:23 2014 -0700 @@ -306,16 +306,18 @@ }; symbol.prototype.quote = function(env) { - 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'); + if (this.cleanName() != 'self') { + 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; + return this; } - return newnode; - } else { - this.dirty = true; - return this; } }; @@ -347,15 +349,15 @@ intlit.prototype.isconstant = floatlit.prototype.isconstant = - strlit.prototype.isconstant = + strlit.prototype.isconstant = lambda.prototype.isconstant = function() { return true; }; object.prototype.isconstant = symbol.prototype.isconstant = - funcall.prototype.isconstant = - op.prototype.isconstant = + funcall.prototype.isconstant = + op.prototype.isconstant = assignment.prototype.isconstant = function() { return false; }