Skip to content

Commit

Permalink
nyan: Fix handling infinity pointer.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Oct 19, 2020
1 parent d2a9005 commit 769e80f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nyan/value/number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Float::Number(const IDToken &token) {

template<>
bool Number<typename Int::storage_type>::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);
}


Expand Down Expand Up @@ -144,8 +144,8 @@ void Number<T>::apply_value(const Value &value, nyan_op operation) {
applier(this->value, change.get(), operation);
}
else {
Float *left = dynamic_cast<Float *>(this);
auto change_value = left->handle_infinity(change, operation);
Float left = static_cast<Float>(*this);
auto change_value = left.handle_infinity(change, operation);
applier(this->value, change_value, nyan_op::ASSIGN);
}
}
Expand All @@ -156,8 +156,8 @@ void Number<T>::apply_value(const Value &value, nyan_op operation) {
applier(this->value, change.get(), operation);
}
else {
Int *left = dynamic_cast<Int *>(this);
auto change_value = left->handle_infinity(change, operation);
Int left = static_cast<Int>(*this);
auto change_value = left.handle_infinity(change, operation);
applier(this->value, change_value, nyan_op::ASSIGN);
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/test.nyan
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ First():

FirstPatch<First>():
member += 3
blub += 3
blob -= 3

Second(First):
member *= 5.5
Expand Down

0 comments on commit 769e80f

Please sign in to comment.