mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-17 04:52:50 +00:00
fixes #21281
(cherry picked from commit 74499e4561)
This commit is contained in:
@@ -1164,7 +1164,15 @@ proc addImplicitGeneric(c: PContext; typeClass: PType, typId: PIdent;
|
||||
# is this a bindOnce type class already present in the param list?
|
||||
for i in 0..<genericParams.len:
|
||||
if genericParams[i].sym.name.id == finalTypId.id:
|
||||
return genericParams[i].typ
|
||||
if typeClass.kind == tyStatic and genericParams[i].typ.kind != tyStatic:
|
||||
# The base type (e.g. from `auto`) was already added as a generic param,
|
||||
# but `static[auto]` requires upgrading it to a `tyStatic` wrapper so
|
||||
# it is instantiated as a compile-time value (`skConst`).
|
||||
genericParams[i].sym.linkTo(typeClass)
|
||||
typeClass.incl tfImplicitTypeParam
|
||||
return typeClass
|
||||
else:
|
||||
return genericParams[i].typ
|
||||
|
||||
let owner = if typeClass.sym != nil: typeClass.sym
|
||||
else: getCurrOwner(c)
|
||||
|
||||
13
tests/vm/t21281.nim
Normal file
13
tests/vm/t21281.nim
Normal file
@@ -0,0 +1,13 @@
|
||||
discard """
|
||||
nimout: '''
|
||||
3
|
||||
3
|
||||
'''
|
||||
"""
|
||||
|
||||
proc f(x: static[auto]) = # doesn't work
|
||||
static: echo x
|
||||
proc g[T](x: static[T]) = # works
|
||||
static: echo x
|
||||
f(3)
|
||||
g(3)
|
||||
Reference in New Issue
Block a user