diff --git a/lib/carto/tree/call.js b/lib/carto/tree/call.js index 6ad6de2..a50c79d 100644 --- a/lib/carto/tree/call.js +++ b/lib/carto/tree/call.js @@ -23,6 +23,15 @@ tree.Call.prototype = { eval: function(env) { var args = this.args.map(function(a) { return a.eval(env) }); + for (var i = 0; i < args.length; i++) { + if (args[i].is === 'undefined') { + return { + is: 'undefined', + value: 'undefined' + }; + } + } + if (this.name in tree.functions) { // 1. return tree.functions[this.name].apply(tree.functions, args); } else { // 2. diff --git a/lib/carto/tree/operation.js b/lib/carto/tree/operation.js index 879a419..4c3da44 100644 --- a/lib/carto/tree/operation.js +++ b/lib/carto/tree/operation.js @@ -11,6 +11,13 @@ tree.Operation.prototype.eval = function(env) { b = this.operands[1].eval(env), temp; + if (a.is === 'undefined' || b.is === 'undefined') { + return { + is: 'undefined', + value: 'undefined' + }; + } + if (a instanceof tree.Dimension && b instanceof tree.Color) { if (this.op === '*' || this.op === '+') { temp = b, b = a, a = temp; diff --git a/test/errorhandling/undefined_variable.mss b/test/errorhandling/undefined_variable.mss index 2c9ea11..15789b0 100644 --- a/test/errorhandling/undefined_variable.mss +++ b/test/errorhandling/undefined_variable.mss @@ -1,3 +1,5 @@ #world[zoom=5] { polygon-fill: @something; + line-color: @something + #111; + marker-fill: darken(@something, 10); }