# HG changeset patch # User Michael Pavone # Date 1409936182 25200 # Node ID 8511aac1ce82cda5743835455c7158afee9f47b7 # Parent dfd204c82849bf487f5cd291a11b2d2274849dcb Fix module references in macros diff -r dfd204c82849 -r 8511aac1ce82 interp.js --- a/interp.js Fri Aug 01 18:56:50 2014 -0700 +++ b/interp.js Fri Sep 05 09:56:22 2014 -0700 @@ -123,6 +123,7 @@ if (typeof ret == 'function') { ret = ret(); } + ret.ismodule = true; this.modules[name] = ret; return ret; } @@ -309,11 +310,15 @@ 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'); + if (val.ismodule) { + return this; + } else { + 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; } - return newnode; } else { this.dirty = true; return this;