diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 10cf6530588e8..ff144ea2e4fa6 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -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 @@ -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 diff --git a/tests/macros/t15691.nim b/tests/macros/t15691.nim new file mode 100644 index 0000000000000..c1e8a8648b8da --- /dev/null +++ b/tests/macros/t15691.nim @@ -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