From 1fcd75d0c70d1f35f6a816ed852c0ca96df3661b Mon Sep 17 00:00:00 2001 From: mertcandav Date: Sat, 9 Mar 2024 10:09:31 +0300 Subject: [PATCH] sema: fix division integer safety --- std/jule/sema/eval.jule | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/std/jule/sema/eval.jule b/std/jule/sema/eval.jule index b5d004313..32094c9a2 100644 --- a/std/jule/sema/eval.jule +++ b/std/jule/sema/eval.jule @@ -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 {