Skip to content

Commit

Permalink
sema: fix enum conversions for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Oct 21, 2024
1 parent 95f37f7 commit 7cd8768
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion std/jule/sema/builtin.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ fn builtinCallerStdJuleIntegratedEmit(mut &e: &eval, mut &fc: &ast::FnCallExpr,
}

if argd.Type.Prim() == nil || !argd.Type.Prim().IsStr() {
e.pushErr(fc.Args[0].Token, build::LogMsg.IncompatibleTypes, types::Kind.Str, argd.Type.Str())
e.pushErr(fc.Args[0].Token, build::LogMsg.IncompatibleTypes, str(types::Kind.Str), argd.Type.Str())
ret nil
}

Expand Down
4 changes: 2 additions & 2 deletions std/jule/sema/comptime.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ impl comptimeValue {
}
prim := d.Type.Prim()
if prim == nil || !prim.IsStr() {
e.pushErr(arg.Token, build::LogMsg.IncompatibleTypes, types::Kind.Str, d.Type.Str())
e.pushErr(arg.Token, build::LogMsg.IncompatibleTypes, str(types::Kind.Str), d.Type.Str())
ret nil
}
ident := d.Constant.ReadStr()
Expand Down Expand Up @@ -1237,7 +1237,7 @@ impl comptimeValue {
}
prim := d.Type.Prim()
if prim == nil || !prim.IsStr() {
e.pushErr(arg.Token, build::LogMsg.IncompatibleTypes, types::Kind.Str, d.Type.Str())
e.pushErr(arg.Token, build::LogMsg.IncompatibleTypes, str(types::Kind.Str), d.Type.Str())
ret nil
}
ident := d.Constant.ReadStr()
Expand Down
16 changes: 8 additions & 8 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ impl eval {
if d.Type.Prim() != nil {
prim := d.Type.Prim()
if !prim.IsU8() && !prim.IsI32() {
self.pushErr(errorToken, build::LogMsg.TypeNotSupportsCastingTo, types::Kind.Str, d.Type.Str())
self.pushErr(errorToken, build::LogMsg.TypeNotSupportsCastingTo, str(types::Kind.Str), d.Type.Str())
ret
}
// Cast constant expressions.
Expand All @@ -1614,14 +1614,14 @@ impl eval {

mut s := d.Type.Slc()
if s == nil {
self.pushErr(errorToken, build::LogMsg.TypeNotSupportsCastingTo, types::Kind.Str, d.Type.Str())
self.pushErr(errorToken, build::LogMsg.TypeNotSupportsCastingTo, str(types::Kind.Str), d.Type.Str())
ret
}

mut t := s.Elem
prim := t.Prim()
if prim == nil || (!prim.IsU8() && !prim.IsI32()) {
self.pushErr(errorToken, build::LogMsg.TypeNotSupportsCastingTo, types::Kind.Str, d.Type.Str())
self.pushErr(errorToken, build::LogMsg.TypeNotSupportsCastingTo, str(types::Kind.Str), d.Type.Str())
ret
}
}
Expand Down Expand Up @@ -2623,7 +2623,7 @@ impl eval {
}

fn evalF32TypeStatic(mut self, ident: &token::Token): &Data {
const kind = types::Kind.F32
const kind: str = types::Kind.F32
const max = types::MaxF32
const min = types::MinF32
const smallestNonZero = types::SmallestNonZeroF32
Expand Down Expand Up @@ -2662,7 +2662,7 @@ impl eval {
}

fn evalF64TypeStatic(mut self, ident: &token::Token): &Data {
const kind = types::Kind.F64
const kind: str = types::Kind.F64
const max = types::MaxF64
const min = types::MinF64
const smallestNonZero = types::SmallestNonZeroF64
Expand Down Expand Up @@ -3808,7 +3808,7 @@ impl binaryEval {
Type: primBool,
}
|:
self.e.pushErr(self.op, build::LogMsg.OperatorNotForJuleType, self.op.Kind, types::Kind.Any)
self.e.pushErr(self.op, build::LogMsg.OperatorNotForJuleType, self.op.Kind, str(types::Kind.Any))
ret nil
}
}
Expand All @@ -3833,7 +3833,7 @@ impl binaryEval {
fn evalStr(mut self): &Data {
mut rk := self.r.Type.Str()
if rk != types::Kind.Str {
self.e.pushErr(self.op, build::LogMsg.IncompatibleTypes, types::Kind.Str, rk)
self.e.pushErr(self.op, build::LogMsg.IncompatibleTypes, str(types::Kind.Str), rk)
ret nil
}

Expand All @@ -3850,7 +3850,7 @@ impl binaryEval {
Type: primBool,
}
|:
self.e.pushErr(self.op, build::LogMsg.OperatorNotForJuleType, self.op.Kind, types::Kind.Str)
self.e.pushErr(self.op, build::LogMsg.OperatorNotForJuleType, self.op.Kind, str(types::Kind.Str))
ret nil
}
}
Expand Down

0 comments on commit 7cd8768

Please sign in to comment.