fix #18990 Regression in proc symbol resolution; Error: attempting to… (#20554)

fix #18990 Regression in proc symbol resolution; Error: attempting to call routine

(cherry picked from commit ea2f2775a7)
This commit is contained in:
Bung
2022-10-13 08:44:45 +08:00
committed by narimiran
parent 322d2f8096
commit ec674e6d5b
4 changed files with 9 additions and 2 deletions

View File

@@ -1248,7 +1248,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
if hasDefault:
def = a[^1]
block determineType:
if genericParams.isGenericParams:
if genericParams != nil and genericParams.len > 0:
def = semGenericStmt(c, def)
if hasUnresolvedArgs(c, def):
def.typ = makeTypeFromExpr(c, def.copyTree)
@@ -1376,7 +1376,7 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
result.flags.excl tfHasMeta
result.n.typ = r
if genericParams.isGenericParams:
if genericParams != nil and genericParams.len > 0:
for n in genericParams:
if {sfUsed, sfAnon} * n.sym.flags == {}:
result.flags.incl tfUnresolved

2
tests/constr/a.nim Normal file
View File

@@ -0,0 +1,2 @@
type A* = object
a: uint8

2
tests/constr/b.nim Normal file
View File

@@ -0,0 +1,2 @@
type B* = object
proc A*(a, b: float): B = discard

3
tests/constr/t18990.nim Normal file
View File

@@ -0,0 +1,3 @@
import a, b
discard A(1f, 1f) # works
proc x(b = A(1f, 1f)) = discard # doesn't work