Remove expr/stmt (#5857)

This commit is contained in:
Arne Döring 2017-07-25 09:28:23 +02:00 • committed by Andreas Rumpf
commit 000b8afd26
168 changed files with 497 additions and 529 deletions

View file

@ -8,17 +8,17 @@ proc isPartOf*[S, T](a: S, b: T): TAnalysisResult {.
magic: "IsPartOf", noSideEffect.}
## not yet exported properly.
template compileTimeAssert(cond: expr) =
template compileTimeAssert(cond) =
when not cond:
{.compile: "is false: " & astToStr(cond).}
template `<|` (a, b: expr) =
template `<|` (a, b) =
compileTimeAssert isPartOf(a, b) == arYes
template `!<|` (a, b: expr) =
template `!<|` (a, b) =
compileTimeAssert isPartOf(a, b) == arNo
template `?<|` (a, b: expr) =
template `?<|` (a, b) =
compileTimeAssert isPartOf(a, b) == arMaybe
type

View file

@ -2,7 +2,7 @@ discard """
output: "x == 45ugh"
"""
template myAssert(cond: expr) =
template myAssert(cond: untyped) =
when 3 <= 3:
let c = cond.astToStr
if not cond:

View file

@ -2,7 +2,7 @@
var
lastId = 0
template genId*: expr =
template genId*: int =
bind lastId
inc(lastId)
lastId

View file

@ -6,7 +6,7 @@ discard """
proc p1(x: int8, y: int): int = return x + y
template tempBind(x, y: expr): expr =
template tempBind(x, y): untyped =
bind p1
p1(x, y)

View file

@ -8,7 +8,7 @@ discard """
proc p1(x: int8, y: int): int = return x + y
proc p1(x: int, y: int8): int = return x - y
template tempBind(x, y: expr): expr =
template tempBind(x, y): untyped =
(bind p1(x, y)) #ERROR_MSG ambiguous call
echo tempBind(1'i8, 2'i8)

View file

@ -1,7 +1,7 @@
# bug #1679
import macros, tables, hashes
proc hash(v: NimNode): Hash = 4 # performance is for suckers
macro test(body: stmt): stmt {.immediate.} =
macro test(body: untyped): typed =
var a = initCountTable[NimNode]()
a.inc(body)

View file

@ -59,7 +59,7 @@ let
((1,1), hiA),
((0,1), hiB)]
template odd*(i: int) : expr =
template odd*(i: int) : untyped =
(i and 1) != 0
proc vidx(hg: HexGrid; col, row: int; i: HexVtxIndex) : Index =

View file

@ -2,109 +2,109 @@ import macros, strutils
# https://github.com/nim-lang/Nim/issues/1512
proc macrobust0 (raw_input: string) =
proc macrobust0(raw_input: string) =
var output = ""
proc p1 (a:string) =
output.add (a)
proc p1(a:string) =
output.add(a)
proc p2 (a:string) = p1 (a)
proc p3 (a:string) = p2 (a)
proc p4 (a:string) = p3 (a)
proc p5 (a:string) = p4 (a)
proc p6 (a:string) = p5 (a)
proc p7 (a:string) = p6 (a)
proc p8 (a:string) = p7 (a)
proc p9 (a:string) = p8 (a)
proc p10 (a:string) = p9 (a)
proc p11 (a:string) = p10 (a)
proc p12 (a:string) = p11 (a)
proc p13 (a:string) = p12 (a)
proc p14 (a:string) = p13 (a)
proc p15 (a:string) = p14 (a)
proc p16 (a:string) = p15 (a)
proc p17 (a:string) = p16 (a)
proc p18 (a:string) = p17 (a)
proc p19 (a:string) = p18 (a)
proc p20 (a:string) = p19 (a)
proc p2(a:string) = p1(a)
proc p3(a:string) = p2(a)
proc p4(a:string) = p3(a)
proc p5(a:string) = p4(a)
proc p6(a:string) = p5(a)
proc p7(a:string) = p6(a)
proc p8(a:string) = p7(a)
proc p9(a:string) = p8(a)
proc p10(a:string) = p9(a)
proc p11(a:string) = p10(a)
proc p12(a:string) = p11(a)
proc p13(a:string) = p12(a)
proc p14(a:string) = p13(a)
proc p15(a:string) = p14(a)
proc p16(a:string) = p15(a)
proc p17(a:string) = p16(a)
proc p18(a:string) = p17(a)
proc p19(a:string) = p18(a)
proc p20(a:string) = p19(a)
let input = $raw_input
for a in input.split ():
p20 (a)
p19 (a)
for a in input.split():
p20(a)
p19(a)
p18 (a)
p17 (a)
p16 (a)
p15 (a)
p14 (a)
p13 (a)
p12 (a)
p11 (a)
p10 (a)
p9 (a)
p8 (a)
p7 (a)
p6 (a)
p5 (a)
p4 (a)
p3 (a)
p2 (a)
p1 (a)
p18(a)
p17(a)
p16(a)
p15(a)
p14(a)
p13(a)
p12(a)
p11(a)
p10(a)
p9(a)
p8(a)
p7(a)
p6(a)
p5(a)
p4(a)
p3(a)
p2(a)
p1(a)
echo output
macro macrobust (raw_input: expr) : stmt =
macro macrobust(raw_input: untyped): untyped =
var output = ""
proc p1 (a:string) =
output.add (a)
proc p1(a:string) =
output.add(a)
proc p2 (a:string) = p1 (a)
proc p3 (a:string) = p2 (a)
proc p4 (a:string) = p3 (a)
proc p5 (a:string) = p4 (a)
proc p6 (a:string) = p5 (a)
proc p7 (a:string) = p6 (a)
proc p8 (a:string) = p7 (a)
proc p9 (a:string) = p8 (a)
proc p10 (a:string) = p9 (a)
proc p11 (a:string) = p10 (a)
proc p12 (a:string) = p11 (a)
proc p13 (a:string) = p12 (a)
proc p14 (a:string) = p13 (a)
proc p15 (a:string) = p14 (a)
proc p16 (a:string) = p15 (a)
proc p17 (a:string) = p16 (a)
proc p18 (a:string) = p17 (a)
proc p19 (a:string) = p18 (a)
proc p20 (a:string) = p19 (a)
proc p2(a:string) = p1(a)
proc p3(a:string) = p2(a)
proc p4(a:string) = p3(a)
proc p5(a:string) = p4(a)
proc p6(a:string) = p5(a)
proc p7(a:string) = p6(a)
proc p8(a:string) = p7(a)
proc p9(a:string) = p8(a)
proc p10(a:string) = p9(a)
proc p11(a:string) = p10(a)
proc p12(a:string) = p11(a)
proc p13(a:string) = p12(a)
proc p14(a:string) = p13(a)
proc p15(a:string) = p14(a)
proc p16(a:string) = p15(a)
proc p17(a:string) = p16(a)
proc p18(a:string) = p17(a)
proc p19(a:string) = p18(a)
proc p20(a:string) = p19(a)
let input = $raw_input
for a in input.split ():
p20 (a)
p19 (a)
for a in input.split():
p20(a)
p19(a)
p18 (a)
p17 (a)
p16 (a)
p15 (a)
p14 (a)
p13 (a)
p12 (a)
p11 (a)
p10 (a)
p9 (a)
p8 (a)
p7 (a)
p6 (a)
p5 (a)
p4 (a)
p3 (a)
p2 (a)
p18(a)
p17(a)
p16(a)
p15(a)
p14(a)
p13(a)
p12(a)
p11(a)
p10(a)
p9(a)
p8(a)
p7(a)
p6(a)
p5(a)
p4(a)
p3(a)
p2(a)
echo output
discard result
@ -134,4 +134,4 @@ macrobust0 """
sdafsdaffsda sdfasadfsadf
fsdasdafsdfa sdfasdfafsda
sdfasdafsadf sdfasdafsdaf sdfasdafsdaf
"""
"""

View file

@ -1,6 +1,6 @@
# Test if the new table constructor syntax works:
template ignoreExpr(e: expr): stmt {.immediate.} =
template ignoreExpr(e) =
discard
# test first class '..' syntactical citizen:

View file

@ -1,13 +1,15 @@
# test the new 'compiles' feature:
template supports(opr, x: expr): bool {.immediate.} =
template supports(opr, x: untyped): bool =
compiles(opr(x)) or compiles(opr(x, x))
template ok(x: expr): stmt =
static: assert(x)
template ok(x) =
static:
assert(x)
template no(x: expr): stmt =
static: assert(not x)
template no(x) =
static:
assert(not x)
type
TObj = object

View file

@ -9,7 +9,6 @@ proc `[]=`*(M: var Matrix; m, n: int; v: M.T) =
M.data[m * M.N + n] = v
# Adapt the Matrix type to the concept's requirements
template Rows*(M: type Matrix): expr = M.M
template Cols*(M: type Matrix): expr = M.N
template Rows*(M: type Matrix): untyped = M.M
template Cols*(M: type Matrix): untyped = M.N
template ValueType*(M: type Matrix): typedesc = M.T

View file

@ -14,10 +14,10 @@ t
'''
"""
template accept(e: expr) =
template accept(e) =
static: assert compiles(e)
template reject(e: expr) =
template reject(e) =
static: assert(not compiles(e))
type
@ -40,4 +40,3 @@ takesContainer(@[4, 5, 6])
takesContainer(@["a", "b"])
takesContainer "test"
reject takesContainer(10)

View file

@ -12,7 +12,7 @@ IMPLICIT VALUE TYPE NAME INT INT
import typetraits, strutils
template reject(e: expr) =
template reject(e) =
static: assert(not compiles(e))
type
@ -60,4 +60,3 @@ reject s.genericAlgorithm "x"
reject s.genericAlgorithm 1.0
reject "str".implicitGeneric
reject implicitGeneric(10)

View file

@ -13,7 +13,7 @@ q[float](0.8, 0.2)
# bug #942
template maybeMod(x: Tinteger, module:Natural):expr =
template maybeMod(x: Tinteger, module:Natural): untyped =
if module > 0: x mod module
else: x

View file

@ -10,7 +10,7 @@ A'''
# bug #1742
template test(): expr =
template test(): untyped =
let a = 0
defer: echo "hi"
a
@ -29,7 +29,7 @@ template atFuncEnd =
defer:
echo "B"
template testB(): expr =
template testB(): untyped =
let a = 0
defer: echo "hi" # Delete this line to make it work
a

View file

@ -9,7 +9,7 @@ for name, value in (n: "v").fieldPairs:
echo name
# This doesn't compile - "expression 'name' has no type (or is ambiguous)".
template wrapper: stmt =
template wrapper: typed =
for name, value in (n: "v").fieldPairs:
echo name
wrapper()

View file

@ -10,7 +10,7 @@ passed.'''
"""
import strutils
template expect_fail(x: expr) =
template expect_fail(x) =
try:
discard x
echo("expected to fail!")

View file

@ -66,7 +66,7 @@ proc setItem[T,D](Akey: T, Avalue: D, ANode: PNode[T,D]): ref TItem[T,D] {.inlin
proc cmp[T:int8|int16|int32|int64|int] (a,b: T): T {.inline.} =
return a-b
template binSearchImpl *(docmp: expr) {.immediate.} =
template binSearchImpl *(docmp: untyped) =
var bFound = false
result = 0
var H = haystack.len - 1

View file

@ -5,7 +5,7 @@ discard """
# bug #3498
template defaultOf[T](t: T): expr = (var d: T; d)
template defaultOf[T](t: T): untyped = (var d: T; d)
echo defaultOf(1) #<- excpected 0

View file

@ -27,5 +27,5 @@ ttmpl[int] #<- crash case #3
# but still allow normal use of [] on non-generic templates
template tarr: expr = [1, 2, 3, 4]
template tarr: untyped = [1, 2, 3, 4]
echo tarr[1]

View file

@ -36,7 +36,7 @@ proc derefExpr(exprRef: string): NimNode {.compileTime.} =
type Mapped[Input; predicate: static[string]] = object
input: Input
macro map(input, predicate: expr): expr =
macro map(input, predicate: untyped): untyped =
let predicate = callsite()[2]
newNimNode(nnkObjConstr).add(
newNimNode(nnkBracketExpr).add(
@ -47,7 +47,7 @@ macro map(input, predicate: expr): expr =
ident"input", input))
proc `[]`(m: Mapped, i: int): auto =
macro buildResult: expr =
macro buildResult: untyped =
newCall(
derefExpr(m.predicate),
newNimNode(nnkBracketExpr).add(

View file

@ -2,7 +2,7 @@ discard """
output: "123100"
"""
template hygienic(val: expr) =
template hygienic(val) =
var x = val
stdout.write x

View file

@ -11,17 +11,15 @@ var x = if 4 != 5:
else:
"no"
macro mymacro(n: expr): stmt {.immediate.} = nil
macro mymacro(n): untyped {.immediate.} =
discard
mymacro:
echo "test"
else:
echo "else part"
if 4 == 3:
echo "bug"
else:
echo "no bug"

View file

@ -11,7 +11,7 @@ type
TTextKind = enum
TFoo, TBar
macro test: stmt =
macro test: untyped =
var x = @[TFoo, TBar]
result = newStmtList()
for i in x:

View file

@ -26,7 +26,7 @@ iterator test2(f: string): Foo =
for i in f:
yield Foo(s: i)
macro test(): stmt =
macro test(): untyped =
for i in test2("asdf"):
echo i.s
@ -39,7 +39,7 @@ import macros
type TType = tuple[s: string]
macro echotest(): stmt =
macro echotest(): untyped =
var t: TType
t.s = ""
t.s.add("test")
@ -61,7 +61,7 @@ proc get_data(d: Td) : string {.compileTime.} =
#result.add("aa") # B
#result = result & "aa" # C
macro m(s:static[Td]) : stmt =
macro m(s:static[Td]) : untyped =
echo get_data(s)
echo get_data(s)
result = newEmptyNode()
@ -77,7 +77,7 @@ proc nilcheck(): NimNode {.compileTime.} =
echo(result.isNil) # true
echo(repr(result)) # nil
macro testnilcheck(): stmt =
macro testnilcheck(): untyped =
result = newNimNode(nnkStmtList)
discard nilcheck()
@ -95,10 +95,10 @@ echo c[0]
# bug #3046
macro sampleMacroInt(i: int): stmt =
macro sampleMacroInt(i: int): untyped =
echo i.intVal
macro sampleMacroBool(b: bool): stmt =
macro sampleMacroBool(b: bool): untyped =
echo b.boolVal
sampleMacroInt(42)

View file

@ -10,7 +10,7 @@ OK
import macros
# Bug from the forum
macro addEcho1(s: untyped): stmt =
macro addEcho1(s: untyped): untyped =
s.body.add(newCall("echo", newStrLitNode("OK")))
result = s
@ -32,7 +32,7 @@ proc foo(): seq[NimNode] {.compiletime.} =
result.add test()
result.add parseExpr("echo(5+56)")
macro bar(): stmt =
macro bar(): typed =
result = newNimNode(nnkStmtList)
let x = foo()
for xx in x:

View file

@ -6,7 +6,7 @@ x: some string'''
import macros
macro debug(n: varargs[expr]): stmt =
macro debug(n: varargs[untyped]): untyped =
# `n` is a Nim AST that contains the whole macro invocation
# this macro returns a list of statements:
result = newNimNode(nnkStmtList, n)

View file

@ -21,7 +21,7 @@ proc dumpit(n: NimNode): string {.compileTime.} =
add(result, dumpit(n[j]))
add(result, ")")
macro dumpAST(n: stmt): stmt {.immediate.} =
macro dumpAST(n): untyped =
# dump AST as a side-effect and return the inner node
let n = callsite()
echo dumpit(n)

View file

@ -13,7 +13,7 @@ Infix
"""
import macros
macro def(x: stmt): stmt {.immediate.} =
macro def(x): untyped =
echo treeRepr(x)
def name(a, b:cint) => nil

View file

@ -11,7 +11,7 @@ proc convertReturns(node, retFutureSym: NimNode): NimNode {.compileTime.} =
for i in 0 .. <node.len:
result[i] = convertReturns(node[i], retFutureSym)
macro async2(prc: stmt): stmt {.immediate.} =
macro async2(prc: untyped): untyped =
expectKind(prc, nnkProcDef)
var outerProcBody = newNimNode(nnkStmtList)

View file

@ -20,7 +20,7 @@ proc parse_template(node: NimNode, value: string) {.compiletime.} =
while index < value.len and
parse_until_symbol(node, value, index): discard
macro tmpli*(body: expr): stmt =
macro tmpli*(body: untyped): typed =
result = newStmtList()
result.add parseExpr("result = \"\"")
result.parse_template body[1].strVal

View file

@ -10,11 +10,11 @@ type
name : string
password : string
macro testUser: expr =
return newLit(User.getType.lispRepr)
macro testUser: string =
result = newLit(User.getType.lispRepr)
macro testGeneric(T: typedesc[Model]): expr =
return newLit(T.getType.lispRepr)
macro testGeneric(T: typedesc[Model]): string=
result = newLit(T.getType.lispRepr)
echo testUser
echo User.testGeneric

View file

@ -22,7 +22,7 @@ proc symToIdent(x: NimNode): NimNode =
result.add symToIdent(c)
# check getTypeInst and getTypeImpl for given symbol x
macro testX(x,inst0: typed; recurse: static[bool]; implX: stmt): typed =
macro testX(x,inst0: typed; recurse: static[bool]; implX: typed): typed =
# check that getTypeInst(x) equals inst0
let inst = x.getTypeInst
let instr = inst.symToIdent.treeRepr

View file

@ -8,7 +8,7 @@ import macros
var gid {.compileTime.} = 3
macro genId(): expr =
macro genId(): int =
result = newIntLitNode(gid)
inc gid

View file

@ -2,7 +2,7 @@ import macros
from uri import `/`
macro test*(a: stmt): stmt {.immediate.} =
macro test*(a: untyped): untyped =
var nodes: tuple[a, b: int]
nodes.a = 4
nodes[1] = 45
@ -20,4 +20,3 @@ macro test*(a: stmt): stmt {.immediate.} =
test:
"hi"

View file

@ -12,7 +12,7 @@ proc testBlock(): string {.compileTime.} =
echo "outer block"
result = "ta-da"
macro mac(n: expr): expr =
macro mac(n: typed): string =
let n = callsite()
expectKind(n, nnkCall)
expectLen(n, 2)

View file

@ -8,7 +8,7 @@ type
TA = tuple[a: int]
PA = ref TA
macro test*(a: stmt): stmt {.immediate.} =
macro test*(a: untyped): untyped =
var val: PA
new(val)
val.a = 4
@ -16,7 +16,7 @@ macro test*(a: stmt): stmt {.immediate.} =
test:
"hi"
macro test2*(a: stmt): stmt {.immediate.} =
macro test2*(a: untyped): untyped =
proc testproc(recurse: int) =
echo "Thats weird"
var o : NimNode = nil
@ -28,4 +28,3 @@ macro test2*(a: stmt): stmt {.immediate.} =
test2:
"hi"

View file

@ -5,7 +5,7 @@ discard """
import
macros, strutils
macro test_macro*(s: string, n: stmt): stmt {.immediate.} =
macro test_macro*(s: string, n: untyped): untyped =
result = newNimNode(nnkStmtList)
var ass : NimNode = newNimNode(nnkAsgn)
add(ass, newIdentNode("str"))
@ -16,4 +16,3 @@ when isMainModule:
test_macro(str):
var i : integer = 123
echo str

View file

@ -3,7 +3,7 @@ import macros,json
var decls{.compileTime.}: seq[NimNode] = @[]
var impls{.compileTime.}: seq[NimNode] = @[]
macro importImpl_forward(name, returns): stmt {.immediate.} =
macro importImpl_forward(name, returns: untyped): untyped =
result = newNimNode(nnkEmpty)
var func_name = newNimNode(nnkAccQuoted)
func_name.add newIdentNode("import")
@ -19,7 +19,7 @@ macro importImpl_forward(name, returns): stmt {.immediate.} =
res[3].add returns
var p1 = newNimNode(nnkIdentDefs)
p1.add newIdentNode("dat")
p1.add newIdentNOde("PJsonNode")
p1.add newIdentNOde("JsonNode")
p1.add newNimNode(nnkEmpty)
res[3].add p1
var p2 = newNimNode(nnkIdentDefs)
@ -38,7 +38,7 @@ macro importImpl_forward(name, returns): stmt {.immediate.} =
decls.add res
echo(repr(res))
macro importImpl(name, returns: expr, body: stmt): stmt {.immediate.} =
macro importImpl(name, returns, body: untyped): typed =
#var res = getAST(importImpl_forward(name, returns))
discard getAST(importImpl_forward(name, returns))
var res = copyNimTree(decls[decls.high])
@ -46,7 +46,7 @@ macro importImpl(name, returns: expr, body: stmt): stmt {.immediate.} =
echo repr(res)
impls.add res
macro okayy:stmt =
macro okayy: typed =
result = newNimNode(nnkStmtList)
for node in decls: result.add node
for node in impls: result.add node

View file

@ -2,8 +2,8 @@
# bug #1944
import macros
template t(e: expr): stmt =
macro m(eNode: expr): stmt =
template t(e: untyped): untyped =
macro m(eNode: untyped): untyped =
echo eNode.treeRepr
m e

View file

@ -1,8 +1,7 @@
import macros
macro foo(x: stmt): stmt =
macro foo(x: untyped): untyped =
echo treerepr(callsite())
result = newNimNode(nnkStmtList)
proc zoo() {.foo.} = echo "hi"

View file

@ -5,7 +5,7 @@ discard """
import
macros, strutils
macro outterMacro*(n: stmt): stmt {.immediate.} =
macro outterMacro*(n, blck: untyped): untyped =
let n = callsite()
var j : string = "hi"
proc innerProc(i: int): string =
@ -27,5 +27,3 @@ var str: string
outterMacro(str):
"hellow"
echo str

View file

@ -1,5 +1,5 @@
import macros
macro case_token(n: stmt): stmt {.immediate.} =
macro case_token(n: untyped): untyped {.immediate.} =
# creates a lexical analyzer from regular expressions
# ... (implementation is an exercise for the reader :-)
nil
@ -18,7 +18,7 @@ case_token: inc i
#bug #488
macro foo: stmt =
macro foo: typed =
var exp = newCall("whatwhat", newIntLitNode(1))
if compiles(getAst(exp)): return exp
else: echo "Does not compute!"

View file

@ -5,7 +5,7 @@ int'''
import macros
macro checkType(ex: stmt; expected: expr): stmt =
macro checkType(ex: typed; expected: string): untyped =
var t = ex.getType()
echo t

View file

@ -11,7 +11,7 @@ static:
nodeB.strVal = "this is a different comment"
doAssert nodeA != nodeB
macro test(a: typed, b: typed): expr =
macro test(a: typed, b: typed): untyped =
newLit(a == b)
doAssert test(1, 1) == true
@ -29,10 +29,10 @@ var a, b: int
doAssert test(a, a) == true
doAssert test(a, b) == false
macro test2: expr =
macro test2: untyped =
newLit(bindSym"Obj" == bindSym"Obj")
macro test3: expr =
macro test3: untyped =
newLit(bindSym"Obj" == bindSym"Other")
doAssert test2() == true

View file

@ -6,7 +6,7 @@ discard """
import macros
macro quoteWords(n: varargs[expr]): expr {.immediate.} =
macro quoteWords(n: varargs[untyped]): untyped =
let n = callsite()
result = newNimNode(nnkBracket, n)
for i in 1..n.len-1:
@ -21,6 +21,3 @@ for w in items(myWordList):
s.add(w)
echo s #OUT thisanexample

View file

@ -4,7 +4,7 @@ discard """
errormsg: "recursive dependency: 'dump'"
"""
macro dump(n: stmt): stmt =
macro dump(n: untyped): untyped =
dump(n)
if kind(n) == nnkNone:
nil

View file

@ -3,10 +3,9 @@ discard """
line: 11
"""
# bug #2372
macro foo(dummy: int): stmt =
macro foo(dummy: int): untyped =
discard
proc takeStr(s: string) = echo s
takeStr foo(12)

View file

@ -13,7 +13,7 @@ false'''
import macros
macro same(a: typedesc, b: typedesc): expr =
macro same(a: typedesc, b: typedesc): untyped =
newLit(a.getType[1].sameType b.getType[1])
echo same(int, int)

View file

@ -25,7 +25,7 @@ type
const data: Tconfig = (@["aa", "bb"], @[11, 22])
macro mymacro(data: static[TConfig]): stmt =
macro mymacro(data: static[TConfig]): untyped =
echo "letters"
for s in items(data.letters):
echo s
@ -43,10 +43,10 @@ const
a : Ta = @[(11, 22), (33, 44)]
b : Tb = (@[55,66], @[77, 88])
macro mA(data: static[Ta]): stmt =
macro mA(data: static[Ta]): untyped =
echo "AST a \n", repr(data)
macro mB(data: static[Tb]): stmt =
macro mB(data: static[Tb]): untyped =
echo "AST b \n", repr(data)
echo data.e[0]
@ -56,13 +56,13 @@ mB(b)
type
Foo[N: static[int], Z: static[string]] = object
macro staticIntMacro(f: static[int]): stmt = echo f
macro staticIntMacro(f: static[int]): untyped = echo f
staticIntMacro 10
var
x: Foo[20, "Test"]
macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12): stmt =
macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12): untyped =
echo N, Z
genericMacro x

View file

@ -9,7 +9,7 @@ proc concat(strings: varargs[string]): string =
result = newString(0)
for s in items(strings): result.add(s)
template processInterpolations(e: expr) =
template processInterpolations(e) =
var s = e[1].strVal
for f in interpolatedFragments(s):
case f.kind
@ -17,7 +17,7 @@ template processInterpolations(e: expr) =
of ikDollar: addDollar()
of ikVar, ikExpr: addExpr(newCall("$", parseExpr(f.value)))
macro formatStyleInterpolation(e: expr): expr =
macro formatStyleInterpolation(e: untyped): untyped =
let e = callsite()
var
formatString = ""
@ -41,7 +41,7 @@ macro formatStyleInterpolation(e: expr): expr =
result[1].strVal = formatString
result[2] = arrayNode
macro concatStyleInterpolation(e: expr): expr =
macro concatStyleInterpolation(e: untyped): untyped =
let e = callsite()
var args: seq[NimNode]
newSeq(args, 0)
@ -71,4 +71,3 @@ var
s2 = formatStyleInterpolation"Hello ${bob}, ${sum(alice.len, bob.len, 2)}$$"
write(stdout, s1 & " | " & s2)

View file

@ -5,7 +5,7 @@ discard """
# feature request #1473
import macros
macro test(text: string): expr =
macro test(text: string): untyped =
try:
result = parseExpr(text.strVal)
except ValueError:

View file

@ -10,7 +10,7 @@ proc test(f: var NimNode) {.compileTime.} =
f = newNimNode(nnkStmtList)
f.add newCall(newIdentNode("echo"), newLit(10))
macro blah(prc: stmt): stmt =
macro blah(prc: untyped): untyped =
result = prc
test(result)

View file

@ -8,7 +8,7 @@ proc (x: int) => typeDesc[proc[void, int]]'''
import macros
macro showType(t:stmt): stmt =
macro showType(t:typed): untyped =
let ty = t.getType
echo t.repr, " => ", ty.repr

View file

@ -2,7 +2,7 @@
# be used as a type
import macros
macro testTypesym (t:stmt): expr =
macro testTypesym (t:typed): untyped =
var ty = t.getType
if ty.typekind == ntyTypedesc:
# skip typedesc get to the real type
@ -31,7 +31,7 @@ static: assert(ref int is testTypesym(ref int))
static: assert(void is testTypesym(void))
macro tts2 (t:stmt, idx:int): expr =
macro tts2 (t:typed, idx:int): untyped =
var ty = t.getType
if ty.typekind == ntyTypedesc:
# skip typedesc get to the real type
@ -46,4 +46,3 @@ static:
assert(tts2(TestFN2, 1) is string)
assert(tts2(TestFN2, 2) is int)
assert(tts2(TestFN2, 3) is float)

View file

@ -212,9 +212,10 @@ proc free(obj: PLiveBullet) =
obj.record = nil
template newExplosion(obj, animation): stmt =
template newExplosion(obj, animation) =
explosions.add(newAnimation(animation, AnimOnce, obj.body.getPos.cp2sfml, obj.body.getAngle))
template newExplosion(obj, animation, angle): stmt =
template newExplosion(obj, animation, angle) =
explosions.add(newAnimation(animation, AnimOnce, obj.body.getPos.cp2sfml, angle))
proc explode*(b: PLiveBullet) =

View file

@ -16,10 +16,10 @@ type
TBar = tuple
x, y: int
template accept(e: expr) =
template accept(e) =
static: assert(compiles(e))
template reject(e: expr) =
template reject(e) =
static: assert(not compiles(e))
proc genericParamRepeated[T: typedesc](a: T, b: T) =

View file

@ -9,7 +9,7 @@ type
data: seq[float]
fWidth, fHeight: int
template `|`(x, y: int): expr = y * m.fWidth + x
template `|`(x, y: int): untyped = y * m.fWidth + x
proc createMatrix*(width, height: int): TMatrix =
result.fWidth = width

View file

@ -7,7 +7,7 @@ type
semistatic[T] =
static[T] or T
template isStatic*(x): expr =
template isStatic*(x): bool =
compiles(static(x))
proc foo(x: semistatic[int]) =

View file

@ -5,6 +5,6 @@ import macros
proc impl(op: static[int]) = echo "impl 1 called"
proc impl(op: static[int], init: int) = echo "impl 2 called"
macro wrapper2: stmt = newCall(bindSym"impl", newLit(0), newLit(0))
macro wrapper2: untyped = newCall(bindSym"impl", newLit(0), newLit(0))
wrapper2() # Code generation for this fails.

View file

@ -26,7 +26,7 @@ type
const data: Tconfig = (@["aa", "bb"], @[11, 22])
macro mymacro(data: static[TConfig]): stmt =
macro mymacro(data: static[TConfig]) =
echo "letters"
for s in items(data.letters):
echo s
@ -44,10 +44,10 @@ const
a : Ta = @[(11, 22), (33, 44)]
b : Tb = (@[55,66], @[77, 88])
macro mA(data: static[Ta]): stmt =
macro mA(data: static[Ta]) =
echo "AST a \n", repr(data)
macro mB(data: static[Tb]): stmt =
macro mB(data: static[Tb]) =
echo "AST b \n", repr(data)
echo data.e[0]
@ -57,13 +57,13 @@ mB(b)
type
Foo[N: static[int], Z: static[string]] = object
macro staticIntMacro(f: static[int]): stmt = echo f
macro staticIntMacro(f: static[int]) = echo f
staticIntMacro 10
var
x: Foo[20, "Test"]
macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12): stmt =
macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12) =
echo N, Z
genericMacro x

View file

@ -74,7 +74,7 @@ matrix_2(tmat, ar2)
matrix_3(tmat, ar1)
matrix_4(tmat, ar2)
template reject(x): stmt =
template reject(x): untyped =
static: assert(not compiles(x))
# test with arrays of wrong size

View file

@ -18,7 +18,7 @@ proc foo(T: typedesc[int or bool]): string =
a = 10
result = "int or bool " & ($a)
template foo(T: typedesc[seq]): expr = "seq"
template foo(T: typedesc[seq]): string = "seq"
test "types can be used as proc params":
# XXX: `check` needs to know that TFoo[int, float] is a type and

View file

@ -1,6 +1,6 @@
import typetraits
template reject(e: expr) =
template reject(e) =
static: assert(not compiles(e))
type

View file

@ -15,7 +15,7 @@ proc fac[T](x: T): T =
if x <= 1: return 1
else: return x.`*`(fac(x-1))
macro macrotest(n: expr): stmt {.immediate.} =
macro macrotest(n: varargs[untyped]): untyped =
let n = callsite()
expectKind(n, nnkCall)
expectMinLen(n, 2)
@ -24,7 +24,7 @@ macro macrotest(n: expr): stmt {.immediate.} =
result.add(newCall("write", n[1], n[i]))
result.add(newCall("writeLine", n[1], newStrLitNode("")))
macro debug(n: expr): stmt {.immediate.} =
macro debug(n: untyped): untyped {.immediate.} =
let n = callsite()
result = newNimNode(nnkStmtList, n)
for i in 1..n.len-1:
@ -82,4 +82,3 @@ for i in 2..6:
when isMainModule:
{.hint: "this is the main file".}

View file

@ -8,7 +8,7 @@ Success'''
var testNumber = 0
template test(opr, a, b, c: expr): stmt {.immediate.} =
template test(opr, a, b, c: untyped): untyped =
# test the expression at compile and runtime
block:
const constExpr = opr(a, b)

View file

@ -118,7 +118,7 @@ proc toTable*[A, B](pairs: openarray[tuple[key: A,
result = initTable[A, B](nextPowerOfTwo(pairs.len+10))
for key, val in items(pairs): result[key] = val
template dollarImpl(): stmt =
template dollarImpl(): typed =
if t.len == 0:
result = "{:}"
else:
@ -305,5 +305,3 @@ proc countTableTest1 =
countTableTest1()
echo true

View file

@ -35,7 +35,7 @@ proc init(my: var TRectangle) =
my.height = 10
my.draw = cast[proc (my: var TFigure) {.nimcall.}](drawRectangle)
macro `!` (n: expr): stmt {.immediate.} =
macro `!` (n: untyped): typed {.immediate.}=
let n = callsite()
result = newNimNode(nnkCall, n)
var dot = newNimNode(nnkDotExpr, n)

View file

@ -1,7 +1,8 @@
discard """
output: '''a 1 b 2 x @[3, 4, 5] y 6 z 7
yay
12'''
12
'''
"""
proc test(a, b: int, x: varargs[int]; y, z: int) =
@ -9,9 +10,10 @@ proc test(a, b: int, x: varargs[int]; y, z: int) =
test 1, 2, 3, 4, 5, 6, 7
template takesBlock(a, b: int, x: varargs[expr]; blck: stmt) =
# XXX maybe this should also work with ``varargs[untyped]``
template takesBlockA(a, b: untyped; x: varargs[typed]; blck: untyped): untyped =
blck
echo a, b
takesBlock 1, 2, "some", 0.90, "random stuff":
takesBlockA 1, 2, "some", 0.90, "random stuff":
echo "yay"

View file

@ -71,7 +71,7 @@ var ri: ref int
gen(ri) # "ref T"
template rem(x: expr) = discard
template rem(x) = discard
#proc rem[T](x: T) = discard
rem unresolvedExpression(undeclaredIdentifier)

View file

@ -2,17 +2,17 @@
# bug #2481
import math
template test(loopCount: int, extraI: int, testBody: stmt): stmt =
template test(loopCount: int, extraI: int, testBody: untyped): typed =
block:
for i in 0..loopCount-1:
testBody
echo "done extraI=", extraI
template test(loopCount: int, extraF: float, testBody: stmt): stmt =
template test(loopCount: int, extraF: float, testBody: untyped): typed =
block:
test(loopCount, round(extraF).int, testBody)
template test(loopCount: int, testBody: stmt): stmt =
template test(loopCount: int, testBody: untyped): typed =
block:
test(loopCount, 0, testBody)
echo "done extraI passed 0"

View file

@ -20,10 +20,10 @@ proc cmpPoint(a, b: Point): int =
if result == 0:
result = cmp(a.y, b.y)
template cross[T](o, a, b: T): expr =
template cross[T](o, a, b: T): untyped =
(a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
template pro(): expr =
template pro(): untyped =
while lr1 > 0 and cross(result[lr1 - 1], result[lr1], p[i]) <= 0:
discard result.pop
lr1 -= 1

View file

@ -24,7 +24,7 @@ var
c.i = 89
template atomicRead(L, x): expr =
template atomicRead(L, x): untyped =
{.locks: [L].}:
x

View file

@ -13,7 +13,7 @@ var
c.i = 89
template atomicRead(L, x): expr =
template atomicRead(L, x): untyped =
{.locks: [L].}:
x

View file

@ -14,7 +14,7 @@ type
processes {.guard: lock.}: array[0..MAX_WORKERS-1, foreign ptr Process]
# Hold a lock for a statement.
template hold(lock: Lock, body: stmt) =
template hold(lock: Lock, body: untyped) =
lock.acquire
defer: lock.release
{.locks: [lock].}:

View file

@ -4,9 +4,11 @@ discard """
"""
# Test operator precedence:
template `@` (x: expr): expr {.immediate.} = self.x
template `@!` (x: expr): expr {.immediate.} = x
template `===` (x: expr): expr {.immediate.} = x
template `@` (x: untyped): untyped {.immediate.} =
`self`.x
template `@!` (x: untyped): untyped = x
template `===` (x: untyped): untyped = x
type
TO = object
@ -34,6 +36,3 @@ var s: TA
assert init(s) == "4"
echo "done"

View file

@ -40,9 +40,9 @@ echo $foo
echo (1, 2, 2)
template `&`(a, b: int): expr = a and b
template `|`(a, b: int): expr = a - b
template `++`(a, b: int): expr = a + b == 8009
template `&`(a, b: int): int = a and b
template `|`(a, b: int): int = a - b
template `++`(a, b: int): bool = a + b == 8009
when true:
let b = 66
@ -62,7 +62,7 @@ when true:
echo booA == booB
template `|`(a, b): expr = (if a.len > 0: a else: b)
template `|`(a, b): untyped = (if a.len > 0: a else: b)
const
tester = "tester"
@ -74,7 +74,7 @@ echo "all"|tester & " " & args
# Test arrow like operators. See also tests/macros/tclosuremacro.nim
proc `+->`(a, b: int): int = a + b*4
template `===>`(a, b: int): expr = a - b shr 1
template `===>`(a, b: int): int = a - b shr 1
echo 3 +-> 2 + 2 and 4
var arrowed = 3+->2 + 2 and 4 # arrowed = 4

View file

@ -1,7 +1,7 @@
# bug #3171
template newDataWindow(): stmt =
template newDataWindow(): untyped =
let eventClosure = proc (closure: pointer): bool {.closure, cdecl.} =
discard

View file

@ -1,6 +1,5 @@
template accept(e: expr) =
template accept(e) =
static: assert(compiles(e))
template reject(e: expr) =
template reject(e) =
static: assert(not compiles(e))

View file

@ -105,10 +105,10 @@ proc pat2kind(pattern: string): FormulaKind =
import macros
proc matchAgainst(n, pattern: NimNode): NimNode {.compileTime.} =
template `@`(current, field: expr): expr =
template `@`(current, field: untyped): untyped =
newDotExpr(current, newIdentNode(astToStr(field)))
template `==@`(n, pattern: expr): expr =
template `==@`(n, pattern: untyped): untyped =
newCall("==", n@kind, newIdentNode($pat2kind($pattern.ident)))
case pattern.kind
@ -126,7 +126,7 @@ proc matchAgainst(n, pattern: NimNode): NimNode {.compileTime.} =
else:
error "invalid pattern"
macro `=~` (n: Formula, pattern: expr): bool =
macro `=~` (n: Formula, pattern: untyped): bool =
result = matchAgainst(n, pattern)
proc isPolyTerm2(n: Formula): bool = n =~ c * x^c

View file

@ -10,7 +10,7 @@ import macros
proc invalidFormatString() =
echo "invalidFormatString"
template formatImpl(handleChar: expr) =
template formatImpl(handleChar: untyped) =
var i = 0
while i < f.len:
if f[i] == '$':
@ -29,11 +29,11 @@ template formatImpl(handleChar: expr) =
i += 1
proc `%`*(f: string, a: openArray[string]): string =
template identity(x: expr): expr = x
template identity(x: untyped): untyped = x
result = ""
formatImpl(identity)
macro optFormat{`%`(f, a)}(f: string{lit}, a: openArray[string]): expr =
macro optFormat{`%`(f, a)}(f: string{lit}, a: openArray[string]): untyped =
result = newNimNode(nnkBracket)
let f = f.strVal
formatImpl(newLit)

View file

@ -2,7 +2,7 @@ discard """
output: "<br>"
"""
template htmlTag(tag: expr) {.immediate.} =
template htmlTag(tag: untyped) =
proc tag(): string = "<" & astToStr(tag) & ">"
htmlTag(br)

View file

@ -4,20 +4,20 @@ discard """
import strutils
template html(name: expr, matter: stmt) {.immediate.} =
template html(name, matter: untyped) =
proc name(): string =
result = "<html>"
matter
result.add("</html>")
template nestedTag(tag: expr) {.immediate.} =
template tag(matter: stmt) {.immediate.} =
template nestedTag(tag: untyped) =
template tag(matter: untyped) =
result.add("<" & astToStr(tag) & ">")
matter
result.add("</" & astToStr(tag) & ">")
template simpleTag(tag: expr) {.immediate.} =
template tag(matter: expr) {.immediate.} =
template simpleTag(tag: untyped) =
template tag(matter: untyped) =
result.add("<$1>$2</$1>" % [astToStr(tag), matter])
nestedTag body

View file

@ -5,7 +5,7 @@ new instantiation
some call of p'''
"""
template once(body: stmt) =
template once(body) =
var x {.global.} = false
if not x:
x = true

View file

@ -4,7 +4,7 @@ discard """
import macros
macro check(ex: expr): stmt =
macro check(ex: untyped): untyped =
var info = ex.lineInfo
var expString = ex.toStrLit
result = quote do:

View file

@ -31,7 +31,7 @@ proc `.=`(x: var T1, f: string{lit}, v: int) =
echo "assigning ", f, " = ", v
x.x = v
template `.()`(x: T1, f: string, args: varargs[expr]): string =
template `.()`(x: T1, f: string, args: varargs[typed]): string =
echo "call to ", f
"dot call"
@ -63,4 +63,3 @@ echo tt.c(10)
assert(not compiles(tt.d("x")))
assert(not compiles(tt.d(1, 2)))

View file

@ -9,7 +9,7 @@ omega 200
import marshal
template testit(x: expr) = discard $$to[type(x)]($$x)
template testit(x) = discard $$to[type(x)]($$x)
var x: array[0..4, array[0..4, string]] = [
["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],

View file

@ -20,12 +20,13 @@ discard """
[Suite] Misc tests'''
"""
import nre
import nre.init
import nre.captures
import nre.find
import nre.split
import nre.match
import nre.replace
import nre.escape
import nre.misc
import nre/init
import nre/captures
import nre/find
import nre/split
import nre/match
import nre/replace
import nre/escape
import nre/misc

View file

@ -149,7 +149,7 @@ proc addChoice(dest: var TPeg, elem: TPeg) =
else: add(dest, elem)
else: add(dest, elem)
template multipleOp(k: TPegKind, localOpt: expr) =
template multipleOp(k: TPegKind, localOpt) =
result.kind = k
result.sons = @[]
for x in items(a):
@ -350,32 +350,32 @@ proc newNonTerminal*(name: string, line, column: int): PNonTerminal {.
result.line = line
result.col = column
template letters*: expr =
template letters*: TPeg =
## expands to ``charset({'A'..'Z', 'a'..'z'})``
charset({'A'..'Z', 'a'..'z'})
template digits*: expr =
template digits*: TPeg =
## expands to ``charset({'0'..'9'})``
charset({'0'..'9'})
template whitespace*: expr =
template whitespace*: TPeg =
## expands to ``charset({' ', '\9'..'\13'})``
charset({' ', '\9'..'\13'})
template identChars*: expr =
template identChars*: TPeg =
## expands to ``charset({'a'..'z', 'A'..'Z', '0'..'9', '_'})``
charset({'a'..'z', 'A'..'Z', '0'..'9', '_'})
template identStartChars*: expr =
template identStartChars*: TPeg =
## expands to ``charset({'A'..'Z', 'a'..'z', '_'})``
charset({'a'..'z', 'A'..'Z', '_'})
template ident*: expr =
template ident*: TPeg =
## same as ``[a-zA-Z_][a-zA-z_0-9]*``; standard identifier
sequence(charset({'a'..'z', 'A'..'Z', '_'}),
*charset({'a'..'z', 'A'..'Z', '0'..'9', '_'}))
template natural*: expr =
template natural*: TPeg =
## same as ``\d+``
+digits
@ -534,10 +534,10 @@ proc bounds*(c: TCaptures,
when not useUnicode:
type
Rune = char
template fastRuneAt(s, i, ch: expr) =
template fastRuneAt(s, i, ch) =
ch = s[i]
inc(i)
template runeLenAt(s, i: expr): expr = 1
template runeLenAt(s, i): untyped = 1
proc isAlpha(a: char): bool {.inline.} = return a in {'a'..'z','A'..'Z'}
proc isUpper(a: char): bool {.inline.} = return a in {'A'..'Z'}
@ -847,7 +847,7 @@ proc findAll*(s: string, pattern: TPeg, start = 0): seq[string] {.
## If it does not match, @[] is returned.
accumulateResult(findAll(s, pattern, start))
template `=~`*(s: string, pattern: TPeg): expr =
template `=~`*(s: string, pattern: TPeg): untyped =
## This calls ``match`` with an implicit declared ``matches`` array that
## can be used in the scope of the ``=~`` call:
##

View file

@ -1,7 +1,7 @@
import macros, parseutils
# Generate tags
macro make(names: openarray[expr]): stmt {.immediate.} =
macro make(names: untyped{nkBracket}): untyped =
result = newStmtList()
for i in 0 .. names.len-1:

View file

@ -5,5 +5,4 @@ type
proc createFoo*(a, b: int): Foo = Foo(fooa: a, foob: b)
template geta*(f: Foo): expr = f.fooa
template geta*(f: Foo): untyped = f.fooa

View file

@ -7,7 +7,7 @@ discard """
proc mpf_get_d(x: int): float = float(x)
proc mpf_cmp_d(a: int; b: float): int = 0
template toFloatHelper(result: expr; tooSmall, tooLarge: stmt) {.immediate.} =
template toFloatHelper(result, tooSmall, tooLarge: untyped) =
result = mpf_get_d(a)
if result == 0.0 and mpf_cmp_d(a,0.0) != 0:
tooSmall

View file

@ -126,7 +126,7 @@ iterator parse_compound_statements(value, identifier: string, index: int): strin
## and returns the initialization of each as an empty statement
## i.e. if x == 5 { ... } becomes if x == 5: nil.
template get_next_ident(expected): stmt =
template get_next_ident(expected) =
var nextIdent: string
discard value.parseWhile(nextIdent, {'$'} + identChars, i)
@ -316,10 +316,10 @@ proc parse_template(node: NimNode, value: string) =
## Nim code into the input `node` AST.
var index = 0
while index < value.len and
parse_until_symbol(node, value, index): nil
parse_until_symbol(node, value, index): discard
macro tmpli*(body: expr): stmt =
macro tmpli*(body: untyped): untyped =
result = newStmtList()
result.add parseExpr("result = \"\"")
@ -330,7 +330,7 @@ macro tmpli*(body: expr): stmt =
parse_template(result, reindent(value))
macro tmpl*(body: expr): stmt =
macro tmpl*(body: untyped): untyped =
result = newStmtList()
var value = if body.kind in nnkStrLit..nnkTripleStrLit: body.strVal

View file

@ -2,7 +2,7 @@
# bug #2629
import sequtils, os
template glob_rst(basedir: string = nil): expr =
template glob_rst(basedir: string = nil): untyped =
if baseDir.isNil:
to_seq(walk_files("*.rst"))
else:

View file

@ -2,7 +2,7 @@
var
e = "abc"
raise newException(EIO, e & "ha!")
raise newException(IOError, e & "ha!")
template t() = echo(foo)
@ -10,7 +10,7 @@ var foo = 12
t()
template test_in(a, b, c: expr): bool {.immediate, dirty.} =
template test_in(a, b, c: untyped): bool {.dirty.} =
var result {.gensym.}: bool = false
false

View file

@ -8,7 +8,7 @@ template baz() =
var y = foo
discard y()
macro test(): stmt =
macro test(): untyped =
result = getAst(baz())
echo(treeRepr(result))

View file

@ -1,15 +1,15 @@
type PNode* = ref object of RootObj
template litNode (name, ty): stmt =
template litNode(name, ty) =
type name* = ref object of PNode
val*: ty
litNode PIntNode, int
import json
template withKey*(j: JsonNode; key: string; varname: expr;
body:stmt): stmt {.immediate.} =
template withKey*(j: JsonNode; key: string; varname,
body: untyped): typed =
if j.hasKey(key):
let varname{.inject.}= j[key]
block:
@ -18,4 +18,3 @@ template withKey*(j: JsonNode; key: string; varname: expr;
var j = parsejson("{\"zzz\":1}")
withkey(j, "foo", x):
echo(x)

View file

@ -1,7 +1,7 @@
# bug #1337
template someIt(a, pred: expr): expr =
template someIt(a, pred): untyped =
var it {.inject.} = 0
pred

View file

@ -43,7 +43,7 @@ template forStatic(index, slice, predicate: untyped) =
block:
const index = i
predicate
template iterateStartingFrom(i: int): stmt =
template iterateStartingFrom(i: int) =
when i <= b:
iteration i
iterateStartingFrom i + 1

View file

@ -4,14 +4,12 @@ discard """
# Test that immediate templates are preferred over non-immediate templates
template foo(a, b: expr) = echo "foo expr"
template foo(a, b: untyped) = echo "foo expr"
template foo(a, b: int) = echo "foo int"
template foo(a, b: float) = echo "foo float"
template foo(a, b: string) = echo "foo string"
template foo(a, b: expr) {.immediate.} = echo "immediate"
template foo(a, b: untyped) {.immediate.} = echo "immediate"
template foo(a, b: bool) = echo "foo bool"
template foo(a, b: char) = echo "foo char"
foo(undeclaredIdentifier, undeclaredIdentifier2)

Some files were not shown because too many files have changed in this diff Show more