Skip to content

Commit

Permalink
sema: fix type inference analysis of untyped slice literals
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 22, 2025
1 parent b8794b8 commit efb83ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
14 changes: 7 additions & 7 deletions std/jule/sema/eval.jule
Original file line number Diff line number Diff line change
Expand Up @@ -941,14 +941,14 @@ impl eval {
if firstElem == nil {
ret nil
}
if self.s.checkDataForTypeInference(firstElem, firstExpr.Token) {
// Check mutability for first element.
const destIsRef = false
self.s.checkValidityForInitExpr(self.target.mutable, destIsRef,
firstElem.Type, firstElem, firstExpr.Token)

// Check mutability for first element.
const destIsRef = false
self.s.checkValidityForInitExpr(self.target.mutable, destIsRef,
firstElem.Type, firstElem, firstExpr.Token)

v = self.evalExpSlice(s, firstElem.Type, firstElem)

v = self.evalExpSlice(s, firstElem.Type, firstElem)
}
self.prefix = prefix
ret v
}
Expand Down
7 changes: 6 additions & 1 deletion std/jule/sema/sema.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2095,14 +2095,19 @@ impl sema {
}
}

fn checkDataForTypeInference(mut self, &v: &Value, &errToken: &token::Token) {
fn checkDataForTypeInference(mut self, &v: &Value, &errToken: &token::Token): bool {
match {
| v.IsNil():
self.pushErr(errToken, build::LogMsg.NilForTypeInference)
ret false
| v.IsVoid():
self.pushErr(errToken, build::LogMsg.VoidForTypeInference)
ret false
| v.Type.Variadic:
self.pushErr(errToken, build::LogMsg.InvalidExprForTypeInference)
ret false
|:
ret true
}
}

Expand Down

0 comments on commit efb83ee

Please sign in to comment.