Skip to content

Commit

Permalink
sacrifice nim-lang#23432 for now
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Aug 20, 2024
1 parent 8d6476d commit 306cd8b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/sem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/semcall.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/generics/tmacrotype.nim
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 306cd8b

Please sign in to comment.