From e29f7d4f021b5086cbb0684a879a9e2697b8fb98 Mon Sep 17 00:00:00 2001 From: heinezen Date: Mon, 19 Oct 2020 09:11:49 +0200 Subject: [PATCH] nyan: Fix handling infinity pointer. --- nyan/value/number.cpp | 12 ++++++------ test/test.nyan | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nyan/value/number.cpp b/nyan/value/number.cpp index 475e03b..9ec4910 100644 --- a/nyan/value/number.cpp +++ b/nyan/value/number.cpp @@ -103,13 +103,13 @@ Float::Number(const IDToken &token) { template<> bool Number::is_infinite() const { - return this->value == INT_POS_INF or this->value == INT_NEG_INF; + return (this->value == INT_POS_INF or this->value == INT_NEG_INF); } template<> bool Number::is_infinite() const { - return this->value == FLOAT_POS_INF or this->value == FLOAT_NEG_INF; + return (this->value == FLOAT_POS_INF or this->value == FLOAT_NEG_INF); } @@ -144,8 +144,8 @@ void Number::apply_value(const Value &value, nyan_op operation) { applier(this->value, change.get(), operation); } else { - Float *left = dynamic_cast(this); - auto change_value = left->handle_infinity(change, operation); + Float left = static_cast(*this); + auto change_value = left.handle_infinity(change, operation); applier(this->value, change_value, nyan_op::ASSIGN); } } @@ -156,8 +156,8 @@ void Number::apply_value(const Value &value, nyan_op operation) { applier(this->value, change.get(), operation); } else { - Int *left = dynamic_cast(this); - auto change_value = left->handle_infinity(change, operation); + Int left = static_cast(*this); + auto change_value = left.handle_infinity(change, operation); applier(this->value, change_value, nyan_op::ASSIGN); } } diff --git a/test/test.nyan b/test/test.nyan index 8ed83a9..15f45ea 100644 --- a/test/test.nyan +++ b/test/test.nyan @@ -15,6 +15,8 @@ First(): FirstPatch(): member += 3 + blub += 3 + blob -= 3 Second(First): member *= 5.5