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