* close #21257

* fix generics
This commit is contained in:
metagn
2023-01-18 23:40:00 +03:00
committed by GitHub
parent 7c6dcfd968
commit ac982d8a96
2 changed files with 23 additions and 1 deletions

View File

@@ -1310,13 +1310,15 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
if hasDefault:
def = a[^1]
block determineType:
var defTyp = typ
if genericParams != nil and genericParams.len > 0:
defTyp = nil
def = semGenericStmt(c, def)
if hasUnresolvedArgs(c, def):
def.typ = makeTypeFromExpr(c, def.copyTree)
break determineType
def = semExprWithType(c, def, {efDetermineType})
def = semExprWithType(c, def, {efDetermineType}, defTyp)
if def.referencesAnotherParam(getCurrOwner(c)):
def.flags.incl nfDefaultRefsParam

20
tests/errmsgs/t21257.nim Normal file
View File

@@ -0,0 +1,20 @@
discard """
action: compile
cmd: "nim check $file"
"""
type AC_WINCTRL_Fields* = distinct uint8
type AC_STATUSA_WSTATE0* {.pure.} = enum
ABOVE = 0x0,
INSIDE = 0x1,
BELOW = 0x2,
type AC_WINCTRL_WINTSEL0* {.pure.} = enum
ABOVE = 0x0,
INSIDE = 0x1,
BELOW = 0x2,
OUTSIDE = 0x3,
proc write*(WINTSEL0: AC_WINCTRL_WINTSEL0 = ABOVE) =
discard