Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* close nim-lang#21257

* fix generics
  • Loading branch information
metagn authored Jan 18, 2023
1 parent 7c6dcfd commit ac982d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions tests/errmsgs/t21257.nim
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ac982d8

Please sign in to comment.