summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-06-29 23:05:18 +0300
committerGitHub <noreply@github.com>2023-06-29 22:05:18 +0200
commit210b10dd0d47c8c79b686a69eb8646df869cf207 (patch)
tree70c70d876558c19a0df4ae5b7c1c06b981aca111 /compiler
parent41ec894cb0aa0b0d233a0f62ff4929d64ddad3a7 (diff)
downloadNim-210b10dd0d47c8c79b686a69eb8646df869cf207.tar.gz
fix nested call regression in generic bodies (#22189)
fixes #22187
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sigmatch.nim11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index f94b4ee60..b2f52ba12 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1140,6 +1140,13 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
       let x = typeRel(c, a, f, flags + {trDontBind})
       if x >= isGeneric:
         return isGeneric
+  
+  of tyFromExpr:
+    if c.c.inGenericContext > 0:
+      # generic type bodies can sometimes compile call expressions
+      # prevent expressions with unresolved types from
+      # being passed as parameters
+      return isNone
   else: discard
 
   case f.kind
@@ -2215,6 +2222,10 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType,
   of isNone:
     # do not do this in ``typeRel`` as it then can't infer T in ``ref T``:
     if a.kind in {tyProxy, tyUnknown}:
+      if a.kind == tyUnknown and c.inGenericContext > 0:
+        # don't bother with fauxMatch mechanism in generic type,
+        # reject match, typechecking will be delayed to instantiation
+        return nil
       inc(m.genericMatches)
       m.fauxMatch = a.kind
       return arg