Catch several more classes of undefined variable errors. Fixes TM#278

This commit is contained in:
Tom MacWright 2011-03-14 11:15:36 -04:00
parent f201dd6e0d
commit 6626b3257e
3 changed files with 18 additions and 0 deletions

View File

@ -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.

View File

@ -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;

View File

@ -1,3 +1,5 @@
#world[zoom=5] {
polygon-fill: @something;
line-color: @something + #111;
marker-fill: darken(@something, 10);
}