correcting the typechecks on the fast-path math

This commit is contained in:
Danny Yoo 2012-02-27 23:10:40 -05:00
parent 8df8168d1c
commit 7dc42c34c6

View File

@ -847,6 +847,12 @@
} }
return sum; return sum;
} else { } else {
if (! isNumber(x)) {
raiseArgumentTypeError(M, '+', 'number', 0, x);
}
if (! isNumber(y)) {
raiseArgumentTypeError(M, '+', 'number', 1, y);
}
return plt.baselib.numbers.add(x, y); return plt.baselib.numbers.add(x, y);
} }
} }
@ -888,6 +894,12 @@
} }
return prod; return prod;
} else { } else {
if (! isNumber(x)) {
raiseArgumentTypeError(M, '*', 'number', 0, x);
}
if (! isNumber(y)) {
raiseArgumentTypeError(M, '*', 'number', 1, y);
}
return plt.baselib.numbers.multiply(x, y); return plt.baselib.numbers.multiply(x, y);
} }
} }
@ -934,6 +946,12 @@
} }
return sum; return sum;
} else { } else {
if (! isNumber(x)) {
raiseArgumentTypeError(M, '-', 'number', 0, x);
}
if (! isNumber(y)) {
raiseArgumentTypeError(M, '-', 'number', 1, y);
}
return plt.baselib.numbers.subtract(x, y); return plt.baselib.numbers.subtract(x, y);
} }
} }
@ -961,6 +979,12 @@
if (typeof(x) === 'number' && typeof(y) === 'number') { if (typeof(x) === 'number' && typeof(y) === 'number') {
return x > y; return x > y;
} else { } else {
if (! isNumber(x)) {
raiseArgumentTypeError(M, '>', 'number', 0, x);
}
if (! isNumber(y)) {
raiseArgumentTypeError(M, '>', 'number', 1, y);
}
return plt.baselib.numbers.greaterThan(x, y); return plt.baselib.numbers.greaterThan(x, y);
} }
} }
@ -993,6 +1017,12 @@
if (typeof(x) === 'number' && typeof(y) === 'number') { if (typeof(x) === 'number' && typeof(y) === 'number') {
return x === y; return x === y;
} else { } else {
if (! isNumber(x)) {
raiseArgumentTypeError(M, '=', 'number', 0, x);
}
if (! isNumber(y)) {
raiseArgumentTypeError(M, '=', 'number', 1, y);
}
return plt.baselib.numbers.equals(x, y); return plt.baselib.numbers.equals(x, y);
} }
} }