From 5917c2d5b7bda82a8feb521890e255cdf08cf718 Mon Sep 17 00:00:00 2001 From: Bung Date: Mon, 12 Dec 2022 13:26:18 +0800 Subject: fix #15836 proc arg return type auto unexpectly match proc with concr… (#21065) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix #15836 proc arg return type auto unexpectly match proc with concrete type * fix #16244 * add test case for #12869 --- compiler/semexprs.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/semexprs.nim') diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 064eae0b7..2efa1259a 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1843,6 +1843,8 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode = var rhsTyp = rhs.typ if rhsTyp.kind in tyUserTypeClasses and rhsTyp.isResolvedUserTypeClass: rhsTyp = rhsTyp.lastSon + if lhs.sym.typ.kind == tyAnything: + rhsTyp = rhsTyp.skipIntLit(c.idgen) if cmpTypes(c, lhs.typ, rhsTyp) in {isGeneric, isEqual}: internalAssert c.config, c.p.resultSym != nil # Make sure the type is valid for the result variable @@ -1916,8 +1918,8 @@ proc semProcBody(c: PContext, n: PNode; expectedType: PType = nil): PNode = else: localError(c.config, c.p.resultSym.info, errCannotInferReturnType % c.p.owner.name.s) - if isInlineIterator(c.p.owner.typ) and c.p.owner.typ[0] != nil and - c.p.owner.typ[0].kind == tyUntyped: + if isIterator(c.p.owner.typ) and c.p.owner.typ[0] != nil and + c.p.owner.typ[0].kind == tyAnything: localError(c.config, c.p.owner.info, errCannotInferReturnType % c.p.owner.name.s) closeScope(c) -- cgit 1.4.1-2-gfad0