Arbitrary (non-falsey) values returned from functions are cast as Anonymous nodes

This commit is contained in:
Matthew Dean
2017-01-06 19:39:23 -08:00
parent ede0587368
commit 809dc509f3
5 changed files with 22 additions and 6 deletions

View File

@@ -48,10 +48,16 @@ Call.prototype.eval = function (context) {
}
if (result !== null && result !== undefined) {
// All returned results must be Nodes,
// so anything other than a Node is a null Node
// Results that that are not nodes are cast as Anonymous nodes
// Falsy values or booleans are returned as empty nodes
if (!(result instanceof Node)) {
result = new Anonymous(null);
if (!result || result === true) {
result = new Anonymous(null);
}
else {
result = new Anonymous(result.toString());
}
}
result._index = this._index;
result._fileInfo = this._fileInfo;