Skip to content

Commit

Permalink
fix #15691 (#21623)
Browse files Browse the repository at this point in the history
`semProcAux` has a check for `checkMinSonsLen(n, bodyPos + 1)`
  • Loading branch information
metagn authored Apr 11, 2023
1 parent 1bb117c commit be06446
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 0 additions & 2 deletions compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,6 @@ proc semMethod(c: PContext, n: PNode): PNode =

proc semConverterDef(c: PContext, n: PNode): PNode =
if not isTopLevel(c): localError(c.config, n.info, errXOnlyAtModuleScope % "converter")
checkSonsLen(n, bodyPos + 1, c.config)
result = semProcAux(c, n, skConverter, converterPragmas)
# macros can transform converters to nothing:
if namePos >= result.safeLen: return result
Expand All @@ -2318,7 +2317,6 @@ proc semConverterDef(c: PContext, n: PNode): PNode =
addConverterDef(c, LazySym(sym: s))

proc semMacroDef(c: PContext, n: PNode): PNode =
checkSonsLen(n, bodyPos + 1, c.config)
result = semProcAux(c, n, skMacro, macroPragmas)
# macros can transform macros to nothing:
if namePos >= result.safeLen: return result
Expand Down
22 changes: 22 additions & 0 deletions tests/macros/t15691.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
discard """
action: compile
"""

import std/macros

macro simplifiedExpandMacros(body: typed): untyped =
result = body

simplifiedExpandMacros:
proc testProc() = discard

simplifiedExpandMacros:
template testTemplate(): untyped = discard

# Error: illformed AST: macro testMacro(): untyped =
simplifiedExpandMacros:
macro testMacro(): untyped = discard

# Error: illformed AST: converter testConverter(x: int): float =
simplifiedExpandMacros:
converter testConverter(x: int): float = discard

0 comments on commit be06446

Please sign in to comment.