Skip to content

Commit

Permalink
test fixing (?) ancient macro subscript bug
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Dec 18, 2023
1 parent 080a072 commit 6434f2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 3 additions & 5 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1694,11 +1694,9 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode =
else:
# We are processing macroOrTmpl[] not in call. Transform it to the
# macro or template call with generic arguments here.
n.transitionSonsKind(nkCall)
case s.kind
of skMacro: result = semMacroExpr(c, n, n, s, flags)
of skTemplate: result = semTemplateExpr(c, n, s, flags)
else: discard
setGenericParams(c, n, nil)
let call = newTreeI(nkCall, n.info, n)
result = semDirectOp(c, call, flags)
of skType:
result = symNodeFromType(c, semTypeNode(c, n, nil), n.info)
else:
Expand Down
7 changes: 7 additions & 0 deletions tests/macros/tsubscript.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
macro foo[T](x: T) = discard
doAssert not compiles(foo[abc])

template bar[T](): untyped = T(0)
let x = bar[int]
doAssert x == 0
doAssert not compiles(bar[abc])

0 comments on commit 6434f2f

Please sign in to comment.