From 306cd8b7a3437805704cedb444a5aeb4a11f9309 Mon Sep 17 00:00:00 2001 From: metagn Date: Sat, 17 Aug 2024 20:01:02 +0300 Subject: [PATCH] sacrifice #23432 for now --- compiler/sem.nim | 2 +- compiler/semcall.nim | 2 +- compiler/semexprs.nim | 2 +- tests/generics/tmacrotype.nim | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler/sem.nim b/compiler/sem.nim index 6df8e345f4afe..55eba124e0ef9 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -501,7 +501,7 @@ const proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym, flags: TExprFlags = {}; expectedType: PType = nil): PNode = - if false and c.inGenericContext > 0 and sfAllUntyped notin sym.flags: + if c.inGenericContext > 0 and sfAllUntyped notin sym.flags: # in generic type body, typed macros can only be instantiated # when the generic type is instantiated result = semGenericStmt(c, n) diff --git a/compiler/semcall.nim b/compiler/semcall.nim index b0444fff484cd..d2642be1a3b33 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -701,7 +701,7 @@ proc semResolvedCall(c: PContext, x: var TCandidate, else: c.inheritBindings(x, expectedType) finalCallee = generateInstance(c, x.calleeSym, x.bindings, n.info) - elif true or c.inGenericContext == 0: + elif c.inGenericContext == 0: # For macros and templates, the resolved generic params # are added as normal params. # This is not done in a generic type body context, as typed macros diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index a8de3bc30aea3..a33477d2541c1 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -27,7 +27,7 @@ const proc semTemplateExpr(c: PContext, n: PNode, s: PSym, flags: TExprFlags = {}; expectedType: PType = nil): PNode = - if false and c.inGenericContext > 0 and sfAllUntyped notin s.flags: + if c.inGenericContext > 0 and sfAllUntyped notin s.flags: # in generic type body, typed templates can only be instantiated # when the generic type is instantiated result = semGenericStmt(c, n) diff --git a/tests/generics/tmacrotype.nim b/tests/generics/tmacrotype.nim index ad42569c03a15..991a92bfdafc2 100644 --- a/tests/generics/tmacrotype.nim +++ b/tests/generics/tmacrotype.nim @@ -1,3 +1,13 @@ +discard """ + # XXX not actually fixed + disabled: true # cannot instantiate: 'T' + # the use of `typedesc` delays the macro unlike `typed` or `untyped` + # but this makes it impossible for overloading to infer the type + # some code depends on `typedesc` needing to be resolved, e.g. tmacrogenerics + # so we can't change it, but maybe we can add a version of `typedesc` that allows generic params + # maybe something like `typed{typedesc}` so it doesn't lift to a generic param +""" + import std/[sequtils, macros] block: # issue #23432