summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-08-20 17:20:35 +0300
committerGitHub <noreply@github.com>2024-08-20 16:20:35 +0200
commit1befb8d4a3559b4611921e851a1fcc64c1b9a17d (patch)
tree09db3b6a54f0609c40f0d8ce2606c363250ae7c3 /compiler
parent6336d2681b16e089b8815fddd0e79abeda9ce85b (diff)
downloadNim-1befb8d4a3559b4611921e851a1fcc64c1b9a17d.tar.gz
include generic bodies in allowMetaTypes (#23968)
fixes #19848

Not sure why this wasn't the case already. The `if cl.allowMetaTypes:
return` line below for `tyFromExpr` [was added 10 years
ago](https://github.com/nim-lang/Nim/commit/d5798b43dec547f372eb49d5a8848a9970b12260).
Hopefully it was just negligence?
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semtypinst.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index e87a4939a..276424512 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -573,6 +573,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
       result.kind = tyUserTypeClassInst
 
   of tyGenericBody:
+    if cl.allowMetaTypes: return
     localError(
       cl.c.config,
       cl.info,
@@ -645,7 +646,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
 
       for i, resulti in result.ikids:
         if resulti != nil:
-          if resulti.kind == tyGenericBody:
+          if resulti.kind == tyGenericBody and not cl.allowMetaTypes:
             localError(cl.c.config, if t.sym != nil: t.sym.info else: cl.info,
               "cannot instantiate '" &
               typeToString(result[i], preferDesc) &