summary refs log tree commit diff stats
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-01-18 23:40:00 +0300
committerGitHub <noreply@github.com>2023-01-18 21:40:00 +0100
commitac982d8a96d4602838d46abc61a8f5385f8c766d (patch)
tree0e09347d6e705fc5d594503dfba8ad49cbba4996
parent7c6dcfd968867ec9b2fee5ca3ef8f251a6faa350 (diff)
downloadNim-ac982d8a96d4602838d46abc61a8f5385f8c766d.tar.gz
close #21257 (#21275)
* close #21257

* fix generics
-rw-r--r--compiler/semtypes.nim4
-rw-r--r--tests/errmsgs/t21257.nim20
2 files changed, 23 insertions, 1 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 844bc2070..aaffa1ea7 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -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
 
diff --git a/tests/errmsgs/t21257.nim b/tests/errmsgs/t21257.nim
new file mode 100644
index 000000000..eecdb1dfe
--- /dev/null
+++ b/tests/errmsgs/t21257.nim
@@ -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