summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
authorBung <crc32@qq.com>2022-12-12 13:26:18 +0800
committerGitHub <noreply@github.com>2022-12-12 06:26:18 +0100
commit5917c2d5b7bda82a8feb521890e255cdf08cf718 (patch)
treea4bc56d847cb090a9ee921cfb6c110adbb598329 /compiler/semexprs.nim
parent3812d91390633113061ceb2b4f3fc61f563a66fb (diff)
downloadNim-5917c2d5b7bda82a8feb521890e255cdf08cf718.tar.gz
fix #15836 proc arg return type auto unexpectly match proc with concr… (#21065)
* fix #15836 proc arg return type auto unexpectly match proc with concrete type

* fix #16244

* add test case for #12869
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim6
1 files changed, 4 insertions, 2 deletions
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)