Skip to content

Commit

Permalink
sema: fix division integer safety
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Mar 9, 2024
1 parent 0c9679d commit 1fcd75d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -4277,6 +4277,13 @@ impl BinaryEval {
self.e.push_err(self.op, LogMsg.DivByZero)
}
d.constant = self.l.constant
let mut prim = d.kind.prim()
match {
| types::is_sig_int(prim.kind):
d.constant.set_i64(d.constant.as_i64())
| types::is_unsig_int(prim.kind):
d.constant.set_u64(d.constant.as_u64())
}
| TokenKind.Percent:
let ok = self.l.constant.mod(*self.r.constant)
if !ok && self.r.constant.as_f64() == 0 {
Expand Down

0 comments on commit 1fcd75d

Please sign in to comment.