From ea2f2775a7398c135408d8b7a444f8337f26ac89 Mon Sep 17 00:00:00 2001 From: Bung Date: Thu, 13 Oct 2022 08:44:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#18990=20Regression=20in=20proc=20symbol?= =?UTF-8?q?=20resolution;=20Error:=20attempting=20to=E2=80=A6=20(#20554)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #18990 Regression in proc symbol resolution; Error: attempting to call routine --- compiler/semtypes.nim | 4 ++-- tests/constr/a.nim | 2 ++ tests/constr/b.nim | 2 ++ tests/constr/t18990.nim | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tests/constr/a.nim create mode 100644 tests/constr/b.nim create mode 100644 tests/constr/t18990.nim diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 60fc8e5c8d..8b1abdd01a 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1298,7 +1298,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) @@ -1426,7 +1426,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 diff --git a/tests/constr/a.nim b/tests/constr/a.nim new file mode 100644 index 0000000000..03788fc57a --- /dev/null +++ b/tests/constr/a.nim @@ -0,0 +1,2 @@ +type A* = object + a: uint8 \ No newline at end of file diff --git a/tests/constr/b.nim b/tests/constr/b.nim new file mode 100644 index 0000000000..437dd05504 --- /dev/null +++ b/tests/constr/b.nim @@ -0,0 +1,2 @@ +type B* = object +proc A*(a, b: float): B = discard \ No newline at end of file diff --git a/tests/constr/t18990.nim b/tests/constr/t18990.nim new file mode 100644 index 0000000000..2f60f3c2c9 --- /dev/null +++ b/tests/constr/t18990.nim @@ -0,0 +1,3 @@ +import a, b +discard A(1f, 1f) # works +proc x(b = A(1f, 1f)) = discard # doesn't work \ No newline at end of file