Skip to content

Commit

Permalink
sema: fix binary constant eval
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Mar 10, 2024
1 parent 4ba3520 commit a1f7689
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 7 additions & 3 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -4101,10 +4101,14 @@ impl BinaryEval {
d.model = d.constant
ret
}
if self.l.constant == self.l.model && self.r.constant != self.r.model {
// Right constant is not pure, use type r's type.
d.kind = self.r.kind
if self.op.kind != TokenKind.Lshift && self.op.kind != TokenKind.Rshift {
if self.l.constant == self.l.model && self.r.constant != self.r.model {
// Right constant is not pure, use type r's type.
d.kind = self.r.kind
prim = d.kind.prim()
}
}
fit_bitsize(d)
cast_const_by_type(prim.kind, d)
}

Expand Down
7 changes: 2 additions & 5 deletions std/jule/sema/scope.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@ impl ScopeChecker {
} else {
self.s.eval(self)
}
eval.unsafety = self.is_unsafe()
let mut r = eval.eval_expr(a.right)
if r == nil {
ret
Expand Down Expand Up @@ -1238,11 +1239,7 @@ impl ScopeChecker {
}

a.setter.kind = a.setter.kind[:a.setter.kind.len-1]
let mut solver = BinaryEval.new(&Eval{
s: self.s,
lookup: self,
unsafety: self.is_unsafe(),
}, a.setter)
let mut solver = BinaryEval.new(eval, a.setter)
r = solver.solve_explicit(l, r)
if r == nil {
ret
Expand Down

0 comments on commit a1f7689

Please sign in to comment.