diff options
-rw-r--r-- | compiler/sigmatch.nim | 4 | ||||
-rw-r--r-- | tests/overload/tstaticoverload.nim | 26 |
2 files changed, 29 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index dfc27bbcb..ff1ad9f0d 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -204,7 +204,9 @@ proc sumGeneric(t: PType): int = if t.sons[i] != nil: result += t.sons[i].sumGeneric break - of tyGenericParam, tyExpr, tyStatic, tyStmt: break + of tyStatic: + return t.sons[0].sumGeneric + 1 + of tyGenericParam, tyExpr, tyStmt: break of tyAlias: t = t.lastSon of tyBool, tyChar, tyEnum, tyObject, tyPointer, tyString, tyCString, tyInt..tyInt64, tyFloat..tyFloat128, diff --git a/tests/overload/tstaticoverload.nim b/tests/overload/tstaticoverload.nim new file mode 100644 index 000000000..b919fc0b1 --- /dev/null +++ b/tests/overload/tstaticoverload.nim @@ -0,0 +1,26 @@ +discard """ +output: ''' +dynamic: let +dynamic: var +static: const +static: literal +static: constant folding +''' +""" + +proc foo(s: string) = + echo "dynamic: ", s + +proc foo(s: static[string]) = + echo "static: ", s + +let l = "let" +let v = "var" +const c = "const" + +foo(l) +foo(v) +foo(c) +foo("literal") +foo("constant" & " " & "folding") + |