mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
...
This commit is contained in:
parent
5c69e1380a
commit
bb96279e9b
@ -361,6 +361,8 @@ public:
|
||||
void TypeError(const Str& msg){ _error("TypeError", msg); }
|
||||
void IndexError(const Str& msg){ _error("IndexError", msg); }
|
||||
void ValueError(const Str& msg){ _error("ValueError", msg); }
|
||||
void ZeroDivisionError(const Str& msg){ _error("ZeroDivisionError", msg); }
|
||||
void ZeroDivisionError(){ _error("ZeroDivisionError", "division by zero"); }
|
||||
void NameError(StrName name){ _error("NameError", fmt("name ", name.escape() + " is not defined")); }
|
||||
void UnboundLocalError(StrName name){ _error("UnboundLocalError", fmt("local variable ", name.escape() + " referenced before assignment")); }
|
||||
void KeyError(PyObject* obj){ _error("KeyError", PK_OBJ_GET(Str, py_repr(obj))); }
|
||||
|
@ -383,7 +383,11 @@ void init_builtins(VM* _vm) {
|
||||
i64 lhs, rhs;
|
||||
if(try_cast_int(lhs_, &lhs) && try_cast_int(rhs_, &rhs)){
|
||||
bool flag = false;
|
||||
if(rhs < 0) {flag = true; rhs = -rhs;}
|
||||
if(rhs < 0) {
|
||||
if(lhs == 0) vm->ZeroDivisionError("0.0 cannot be raised to a negative power");
|
||||
flag = true;
|
||||
rhs = -rhs;
|
||||
}
|
||||
i64 ret = 1;
|
||||
while(rhs){
|
||||
if(rhs & 1) ret *= lhs;
|
||||
|
Loading…
x
Reference in New Issue
Block a user