From efb83ee4d031f4d9504f7465771c444ba6e7e8e1 Mon Sep 17 00:00:00 2001 From: mertcandav Date: Wed, 22 Jan 2025 22:51:00 +0300 Subject: [PATCH] sema: fix type inference analysis of untyped slice literals --- std/jule/sema/eval.jule | 14 +++++++------- std/jule/sema/sema.jule | 7 ++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/std/jule/sema/eval.jule b/std/jule/sema/eval.jule index e16a8fb3..1c014c18 100644 --- a/std/jule/sema/eval.jule +++ b/std/jule/sema/eval.jule @@ -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 } diff --git a/std/jule/sema/sema.jule b/std/jule/sema/sema.jule index 44099f99..f6309abb 100644 --- a/std/jule/sema/sema.jule +++ b/std/jule/sema/sema.jule @@ -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 } }