diff --git a/src/runtime/int.cpp b/src/runtime/int.cpp index ff3566610113ad12ea570dd5cd858a48e0c7e8ed..e7e8dc8ba35707aee651548d80e78b8d02f39635 100644 --- a/src/runtime/int.cpp +++ b/src/runtime/int.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include <cmath> #include <sstream> #include "core/common.h" @@ -273,11 +274,15 @@ extern "C" Box* intMul(BoxedInt* lhs, Box *rhs) { extern "C" Box* intPow(BoxedInt* lhs, Box *rhs) { assert(lhs->cls == int_cls); - if (rhs->cls != int_cls) { + if (rhs->cls == int_cls) { + BoxedInt *rhs_int = static_cast<BoxedInt*>(rhs); + return boxInt(pow_i64_i64(lhs->n, rhs_int->n)); + } else if (rhs->cls == float_cls) { + BoxedFloat *rhs_float = static_cast<BoxedFloat*>(rhs); + return boxFloat(pow(lhs->n, rhs_float->d)); + } else { return NotImplemented; } - BoxedInt *rhs_int = static_cast<BoxedInt*>(rhs); - return boxInt(pow_i64_i64(lhs->n, rhs_int->n)); } extern "C" Box* intRShift(BoxedInt* lhs, Box *rhs) { diff --git a/test/tests/polymorphism_small.py b/test/tests/polymorphism_small.py index a04c543a4f46dfaf299001cf52a0732f8cdf52cd..b6fcfa598e4203152573c3c9312d074678ca90ee 100644 --- a/test/tests/polymorphism_small.py +++ b/test/tests/polymorphism_small.py @@ -1,5 +1,3 @@ -# expected: fail - class Union(object): def __init__(self, subs): self.subs = subs