Skip to content

Commit

Permalink
fix: Integer division issue
Browse files Browse the repository at this point in the history
Closes #96
  • Loading branch information
Vardan2009 committed May 29, 2024
1 parent 8503174 commit 22bdec4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions core/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def idived_by(self, other: Value) -> ResultTuple:
if isinstance(other, Number):
if other.value == 0:
return None, RTError(other.pos_start, other.pos_end, "Division by zero", self.context)

return Number(self.value // other.value).set_context(self.context), None
return Number(int(self.value // other.value)).set_context(self.context), None
else:
return None, Value.illegal_operation(self, other)

Expand Down
2 changes: 1 addition & 1 deletion core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def arith_expr(self) -> ParseResult[Node]:
return self.bin_op(self.term, (TT_PLUS, TT_MINUS))

def term(self) -> ParseResult[Node]:
return self.bin_op(self.factor, (TT_MUL, TT_DIV, TT_MOD))
return self.bin_op(self.factor, (TT_MUL, TT_DIV, TT_MOD, TT_IDIV))

def factor(self) -> ParseResult[Node]:
res = ParseResult[Node]()
Expand Down

0 comments on commit 22bdec4

Please sign in to comment.