basic: exponentiation to raise correct errors

This commit is contained in:
minjaesong
2020-12-16 20:17:59 +09:00
parent 47f413a9e0
commit 45aebd2a10

View File

@@ -687,7 +687,12 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
});
},
"^" : function(lnum, stmtnum, args) {
return twoArgNum(lnum, stmtnum, args, (lh,rh) => Math.pow(lh, rh));
return twoArgNum(lnum, stmtnum, args, (lh,rh) => {
let r = Math.pow(lh, rh);
if (isNaN(r)) throw lang.badFunctionCallFormat();
if (!isFinite(r)) throw lang.divByZero;
return r;
});
},
"TO" : function(lnum, stmtnum, args) {
return twoArgNum(lnum, stmtnum, args, (from, to) => new ForGen(from, to, 1));