This commit is contained in:
Andreas Rumpf
2016-08-26 13:02:52 +02:00
parent b9322010e9
commit 89f3e21fc8
2 changed files with 18 additions and 0 deletions

View File

@@ -1396,6 +1396,11 @@ proc semMacroDef(c: PContext, n: PNode): PNode =
if namePos >= result.safeLen: return result
var s = result.sons[namePos].sym
var t = s.typ
var allUntyped = true
for i in 1 .. t.n.len-1:
let param = t.n.sons[i].sym
if param.typ.kind != tyExpr: allUntyped = false
if allUntyped: incl(s.flags, sfAllUntyped)
if t.sons[0] == nil: localError(n.info, errXNeedsReturnType, "macro")
if n.sons[bodyPos].kind == nkEmpty:
localError(n.info, errImplOfXexpected, s.name.s)

View File

@@ -0,0 +1,13 @@
discard """
output: '''!!Hi!!'''
"""
# bug #4658
import future
var x = 123
proc twice[T](f: T -> T): T -> T = (x: T) => f(f(x))
proc quote(s: string): string = "!" & s & "!"
echo twice(quote)("Hi")