Skip to content

Commit

Permalink
sema: optimize enum item expression analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Apr 9, 2024
1 parent ecd668b commit bd51cca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions std/jule/sema/sema.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ impl Sema {
}

fn check_enum_items_str(mut &self, mut &e: &Enum) {
let mut eval = self.eval(self)
for (_, mut item) in e.items {
if item.auto_expr() {
item.value = &Value{
Expand All @@ -1118,7 +1119,7 @@ impl Sema {
}
item.value.data.model = item.value.data.constant
} else {
let mut d = self.eval(self).eval_expr(item.value.expr)
let mut d = eval.eval_expr(item.value.expr)
if d == nil {
continue
}
Expand All @@ -1136,6 +1137,7 @@ impl Sema {
fn check_enum_items_int(mut &self, mut &e: &Enum) {
let prim = e.kind.kind.prim()
let mut max = u64(types::max(prim.to_str()))
let mut eval = self.eval(self)
for (i, mut item) in e.items {
if max == 0 {
self.push_err(item.token, LogMsg.OverflowLimits)
Expand All @@ -1154,7 +1156,7 @@ impl Sema {
}
item.value.data.model = item.value.data.constant
} else {
let mut d = self.eval(self).eval_expr(item.value.expr)
let mut d = eval.eval_expr(item.value.expr)
if d == nil {
continue
}
Expand Down

0 comments on commit bd51cca

Please sign in to comment.