diff options
author | Arne Döring <arne.doering@gmx.net> | 2017-07-25 09:28:23 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-07-25 09:28:23 +0200 |
commit | 000b8afd26fa16684a116d9afe798ea94df9c270 (patch) | |
tree | e5295df748b90c5027e44adfa3a442031534572c /tests | |
parent | 52ff244d5d2775fa4d13f4e2b9a996f411281312 (diff) | |
download | Nim-000b8afd26fa16684a116d9afe798ea94df9c270.tar.gz |
Remove expr/stmt (#5857)
Diffstat (limited to 'tests')
137 files changed, 390 insertions, 418 deletions
diff --git a/tests/alias/talias.nim b/tests/alias/talias.nim index 810ea2095..a8f1b0dd0 100644 --- a/tests/alias/talias.nim +++ b/tests/alias/talias.nim @@ -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 diff --git a/tests/assert/tuserassert.nim b/tests/assert/tuserassert.nim index 7bb0a7fc0..274c78921 100644 --- a/tests/assert/tuserassert.nim +++ b/tests/assert/tuserassert.nim @@ -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: diff --git a/tests/bind/mbind3.nim b/tests/bind/mbind3.nim index aad080223..1a7d3b63b 100644 --- a/tests/bind/mbind3.nim +++ b/tests/bind/mbind3.nim @@ -2,7 +2,7 @@ var lastId = 0 -template genId*: expr = +template genId*: int = bind lastId inc(lastId) lastId diff --git a/tests/bind/tbind1.nim b/tests/bind/tbind1.nim index 2665d0b5c..9b13a7d11 100644 --- a/tests/bind/tbind1.nim +++ b/tests/bind/tbind1.nim @@ -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) diff --git a/tests/bind/tbind2.nim b/tests/bind/tbind2.nim index 0e0cbd788..799b14381 100644 --- a/tests/bind/tbind2.nim +++ b/tests/bind/tbind2.nim @@ -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) diff --git a/tests/ccgbugs/tnocodegen_for_compiletime.nim b/tests/ccgbugs/tnocodegen_for_compiletime.nim index a88ba4b32..b44e9f8c9 100644 --- a/tests/ccgbugs/tnocodegen_for_compiletime.nim +++ b/tests/ccgbugs/tnocodegen_for_compiletime.nim @@ -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) diff --git a/tests/ccgbugs/tuple_canon.nim b/tests/ccgbugs/tuple_canon.nim index a607f9cab..45fed8eee 100644 --- a/tests/ccgbugs/tuple_canon.nim +++ b/tests/ccgbugs/tuple_canon.nim @@ -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 = diff --git a/tests/closure/tmacrobust1512.nim b/tests/closure/tmacrobust1512.nim index 95681e750..5f13e8286 100644 --- a/tests/closure/tmacrobust1512.nim +++ b/tests/closure/tmacrobust1512.nim @@ -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 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 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) let input = $raw_input - 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) + 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) echo output -macro macrobust (raw_input: expr) : stmt = +macro macrobust(raw_input: untyped): untyped = var output = "" - 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 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) let input = $raw_input - 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) + 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) echo output discard result @@ -134,4 +134,4 @@ macrobust0 """ sdafsdaffsda sdfasadfsadf fsdasdafsdfa sdfasdfafsda sdfasdafsadf sdfasdafsdaf sdfasdafsdaf -""" \ No newline at end of file +""" diff --git a/tests/collections/ttableconstr.nim b/tests/collections/ttableconstr.nim index a9262e70e..884378a76 100644 --- a/tests/collections/ttableconstr.nim +++ b/tests/collections/ttableconstr.nim @@ -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: diff --git a/tests/compiles/tcompiles.nim b/tests/compiles/tcompiles.nim index b3d9c17ce..1a21315c8 100644 --- a/tests/compiles/tcompiles.nim +++ b/tests/compiles/tcompiles.nim @@ -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 diff --git a/tests/concepts/matrix.nim b/tests/concepts/matrix.nim index a30cbe4f3..47a709f80 100644 --- a/tests/concepts/matrix.nim +++ b/tests/concepts/matrix.nim @@ -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 - diff --git a/tests/concepts/tmanual.nim b/tests/concepts/tmanual.nim index 43290a6ad..c917f5022 100644 --- a/tests/concepts/tmanual.nim +++ b/tests/concepts/tmanual.nim @@ -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) - diff --git a/tests/concepts/tstackconcept.nim b/tests/concepts/tstackconcept.nim index b6ead2c2b..2238dacb6 100644 --- a/tests/concepts/tstackconcept.nim +++ b/tests/concepts/tstackconcept.nim @@ -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) - diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim index 99adcfd30..662d2725a 100644 --- a/tests/discard/tdiscardable.nim +++ b/tests/discard/tdiscardable.nim @@ -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 diff --git a/tests/exception/tdefer1.nim b/tests/exception/tdefer1.nim index cb3d09b01..b84ba7681 100644 --- a/tests/exception/tdefer1.nim +++ b/tests/exception/tdefer1.nim @@ -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 diff --git a/tests/fields/tfields_in_template.nim b/tests/fields/tfields_in_template.nim index 9352a7a51..b7d5d2343 100644 --- a/tests/fields/tfields_in_template.nim +++ b/tests/fields/tfields_in_template.nim @@ -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() diff --git a/tests/float/tfloat7.nim b/tests/float/tfloat7.nim index 2337d1dd4..5fd0d43d9 100644 --- a/tests/float/tfloat7.nim +++ b/tests/float/tfloat7.nim @@ -10,7 +10,7 @@ passed.''' """ import strutils -template expect_fail(x: expr) = +template expect_fail(x) = try: discard x echo("expected to fail!") diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim index 0dbd5b03c..d014eb998 100644 --- a/tests/generics/tgeneric3.nim +++ b/tests/generics/tgeneric3.nim @@ -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 diff --git a/tests/generics/tgenerictmpl.nim b/tests/generics/tgenerictmpl.nim index c71ce4e2e..e18f020c2 100644 --- a/tests/generics/tgenerictmpl.nim +++ b/tests/generics/tgenerictmpl.nim @@ -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 diff --git a/tests/generics/tgenerictmpl2.nim b/tests/generics/tgenerictmpl2.nim index 0ecaf9ded..ac92d3281 100644 --- a/tests/generics/tgenerictmpl2.nim +++ b/tests/generics/tgenerictmpl2.nim @@ -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] diff --git a/tests/generics/tunique_type.nim b/tests/generics/tunique_type.nim index da2f9e4b2..ccb367ac8 100644 --- a/tests/generics/tunique_type.nim +++ b/tests/generics/tunique_type.nim @@ -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( diff --git a/tests/gensym/tgensym.nim b/tests/gensym/tgensym.nim index 3c85b0b83..e33a2783f 100644 --- a/tests/gensym/tgensym.nim +++ b/tests/gensym/tgensym.nim @@ -2,7 +2,7 @@ discard """ output: "123100" """ -template hygienic(val: expr) = +template hygienic(val) = var x = val stdout.write x diff --git a/tests/lexer/tind1.nim b/tests/lexer/tind1.nim index 6a975d5be..8a2aea9b2 100644 --- a/tests/lexer/tind1.nim +++ b/tests/lexer/tind1.nim @@ -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" - - diff --git a/tests/macros/tbindsym.nim b/tests/macros/tbindsym.nim index e1e3b5112..6289d3eb2 100644 --- a/tests/macros/tbindsym.nim +++ b/tests/macros/tbindsym.nim @@ -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: diff --git a/tests/macros/tbugs.nim b/tests/macros/tbugs.nim index 1bfce6bc4..990edf1e2 100644 --- a/tests/macros/tbugs.nim +++ b/tests/macros/tbugs.nim @@ -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) diff --git a/tests/macros/tcomplexecho.nim b/tests/macros/tcomplexecho.nim index f7f933c1c..0b70a3ef7 100644 --- a/tests/macros/tcomplexecho.nim +++ b/tests/macros/tcomplexecho.nim @@ -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: diff --git a/tests/macros/tdebugstmt.nim b/tests/macros/tdebugstmt.nim index 421f8fd14..740ae7b05 100644 --- a/tests/macros/tdebugstmt.nim +++ b/tests/macros/tdebugstmt.nim @@ -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) diff --git a/tests/macros/tdumpast2.nim b/tests/macros/tdumpast2.nim index 6b694fa77..c4c591b2a 100644 --- a/tests/macros/tdumpast2.nim +++ b/tests/macros/tdumpast2.nim @@ -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) diff --git a/tests/macros/texprcolonexpr.nim b/tests/macros/texprcolonexpr.nim index 3b2c86b77..59c799771 100644 --- a/tests/macros/texprcolonexpr.nim +++ b/tests/macros/texprcolonexpr.nim @@ -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 diff --git a/tests/macros/tgensym.nim b/tests/macros/tgensym.nim index a4d1a3606..955168939 100644 --- a/tests/macros/tgensym.nim +++ b/tests/macros/tgensym.nim @@ -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) diff --git a/tests/macros/tgentemplates.nim b/tests/macros/tgentemplates.nim index 764b94bc7..301d58c6a 100644 --- a/tests/macros/tgentemplates.nim +++ b/tests/macros/tgentemplates.nim @@ -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 diff --git a/tests/macros/tgettype.nim b/tests/macros/tgettype.nim index 0eab6c0a0..8b787b022 100644 --- a/tests/macros/tgettype.nim +++ b/tests/macros/tgettype.nim @@ -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 diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim index f89aa5e0b..8e1d9bc13 100644 --- a/tests/macros/tgettypeinst.nim +++ b/tests/macros/tgettypeinst.nim @@ -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 diff --git a/tests/macros/tidgen.nim b/tests/macros/tidgen.nim index 2fe9e0f82..88322b227 100644 --- a/tests/macros/tidgen.nim +++ b/tests/macros/tidgen.nim @@ -8,7 +8,7 @@ import macros var gid {.compileTime.} = 3 -macro genId(): expr = +macro genId(): int = result = newIntLitNode(gid) inc gid diff --git a/tests/macros/tmacro1.nim b/tests/macros/tmacro1.nim index 2dd5c31df..ac6bd02a5 100644 --- a/tests/macros/tmacro1.nim +++ b/tests/macros/tmacro1.nim @@ -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" - diff --git a/tests/macros/tmacro2.nim b/tests/macros/tmacro2.nim index 17f312925..72972c0c1 100644 --- a/tests/macros/tmacro2.nim +++ b/tests/macros/tmacro2.nim @@ -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) diff --git a/tests/macros/tmacro3.nim b/tests/macros/tmacro3.nim index d7421ff7f..a1dc4f371 100644 --- a/tests/macros/tmacro3.nim +++ b/tests/macros/tmacro3.nim @@ -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" - diff --git a/tests/macros/tmacro4.nim b/tests/macros/tmacro4.nim index fb07941a9..164afaeb7 100644 --- a/tests/macros/tmacro4.nim +++ b/tests/macros/tmacro4.nim @@ -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 - diff --git a/tests/macros/tmacro5.nim b/tests/macros/tmacro5.nim index d7a4fe8c8..1c60e1ffd 100644 --- a/tests/macros/tmacro5.nim +++ b/tests/macros/tmacro5.nim @@ -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 diff --git a/tests/macros/tmacro_in_template.nim b/tests/macros/tmacro_in_template.nim index 8f7753cea..9668495df 100644 --- a/tests/macros/tmacro_in_template.nim +++ b/tests/macros/tmacro_in_template.nim @@ -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 diff --git a/tests/macros/tmacroaspragma.nim b/tests/macros/tmacroaspragma.nim index 0e5c352b3..5f06f2425 100644 --- a/tests/macros/tmacroaspragma.nim +++ b/tests/macros/tmacroaspragma.nim @@ -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" - diff --git a/tests/macros/tmacros1.nim b/tests/macros/tmacros1.nim index 1a1073a44..9e3ab028b 100644 --- a/tests/macros/tmacros1.nim +++ b/tests/macros/tmacros1.nim @@ -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 - - diff --git a/tests/macros/tmacrostmt.nim b/tests/macros/tmacrostmt.nim index 23e2f358c..6f648958f 100644 --- a/tests/macros/tmacrostmt.nim +++ b/tests/macros/tmacrostmt.nim @@ -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!" diff --git a/tests/macros/tmacrotypes.nim b/tests/macros/tmacrotypes.nim index 991668930..e8a68c34d 100644 --- a/tests/macros/tmacrotypes.nim +++ b/tests/macros/tmacrotypes.nim @@ -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 diff --git a/tests/macros/tnodecompare.nim b/tests/macros/tnodecompare.nim index b9cf7df48..5ffb495b1 100644 --- a/tests/macros/tnodecompare.nim +++ b/tests/macros/tnodecompare.nim @@ -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 diff --git a/tests/macros/tquotewords.nim b/tests/macros/tquotewords.nim index 48fcafd62..fa00ba9de 100644 --- a/tests/macros/tquotewords.nim +++ b/tests/macros/tquotewords.nim @@ -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 - - - diff --git a/tests/macros/trecmacro.nim b/tests/macros/trecmacro.nim index 28b6db530..69ebe3da3 100644 --- a/tests/macros/trecmacro.nim +++ b/tests/macros/trecmacro.nim @@ -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 diff --git a/tests/macros/treturnsempty.nim b/tests/macros/treturnsempty.nim index 7af26a747..a5a678af3 100644 --- a/tests/macros/treturnsempty.nim +++ b/tests/macros/treturnsempty.nim @@ -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) - diff --git a/tests/macros/tsametype.nim b/tests/macros/tsametype.nim index 34296015f..865fb4cb8 100644 --- a/tests/macros/tsametype.nim +++ b/tests/macros/tsametype.nim @@ -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) diff --git a/tests/macros/tstaticparamsmacro.nim b/tests/macros/tstaticparamsmacro.nim index f6ecb3a9f..ea59936e0 100644 --- a/tests/macros/tstaticparamsmacro.nim +++ b/tests/macros/tstaticparamsmacro.nim @@ -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 diff --git a/tests/macros/tstringinterp.nim b/tests/macros/tstringinterp.nim index bc79cdaba..305f40ac5 100644 --- a/tests/macros/tstringinterp.nim +++ b/tests/macros/tstringinterp.nim @@ -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) - diff --git a/tests/macros/ttryparseexpr.nim b/tests/macros/ttryparseexpr.nim index c7bbc8e5b..54442b662 100644 --- a/tests/macros/ttryparseexpr.nim +++ b/tests/macros/ttryparseexpr.nim @@ -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: diff --git a/tests/macros/tvarnimnode.nim b/tests/macros/tvarnimnode.nim index ab0f66caa..26c9b1f1a 100644 --- a/tests/macros/tvarnimnode.nim +++ b/tests/macros/tvarnimnode.nim @@ -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) diff --git a/tests/macros/typesapi.nim b/tests/macros/typesapi.nim index 670b39c9e..cdbfc0ad2 100644 --- a/tests/macros/typesapi.nim +++ b/tests/macros/typesapi.nim @@ -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 diff --git a/tests/macros/typesapi2.nim b/tests/macros/typesapi2.nim index 2e59d2154..0130049c0 100644 --- a/tests/macros/typesapi2.nim +++ b/tests/macros/typesapi2.nim @@ -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) - diff --git a/tests/manyloc/keineschweine/keineschweine.nim b/tests/manyloc/keineschweine/keineschweine.nim index 804a22852..c0f1bc031 100644 --- a/tests/manyloc/keineschweine/keineschweine.nim +++ b/tests/manyloc/keineschweine/keineschweine.nim @@ -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) = diff --git a/tests/metatype/tbindtypedesc.nim b/tests/metatype/tbindtypedesc.nim index 4f027407b..b287aad01 100644 --- a/tests/metatype/tbindtypedesc.nim +++ b/tests/metatype/tbindtypedesc.nim @@ -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) = diff --git a/tests/metatype/tmatrix.nim b/tests/metatype/tmatrix.nim index 5acd4389e..4fd32a932 100644 --- a/tests/metatype/tmatrix.nim +++ b/tests/metatype/tmatrix.nim @@ -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 diff --git a/tests/metatype/tsemistatic.nim b/tests/metatype/tsemistatic.nim index a13175ba8..3f36abde9 100644 --- a/tests/metatype/tsemistatic.nim +++ b/tests/metatype/tsemistatic.nim @@ -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]) = diff --git a/tests/metatype/tstatic_overloading.nim b/tests/metatype/tstatic_overloading.nim index ce51052b7..9c065e48d 100644 --- a/tests/metatype/tstatic_overloading.nim +++ b/tests/metatype/tstatic_overloading.nim @@ -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. diff --git a/tests/metatype/tstaticparammacro.nim b/tests/metatype/tstaticparammacro.nim index 5c7c5e6af..bd3295874 100644 --- a/tests/metatype/tstaticparammacro.nim +++ b/tests/metatype/tstaticparammacro.nim @@ -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 diff --git a/tests/metatype/tstaticparams.nim b/tests/metatype/tstaticparams.nim index 69b62e4a6..ad6aa6589 100644 --- a/tests/metatype/tstaticparams.nim +++ b/tests/metatype/tstaticparams.nim @@ -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 diff --git a/tests/metatype/ttypedesc1.nim b/tests/metatype/ttypedesc1.nim index d78c62a94..e9eee581f 100644 --- a/tests/metatype/ttypedesc1.nim +++ b/tests/metatype/ttypedesc1.nim @@ -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 diff --git a/tests/metatype/tymatrix.nim b/tests/metatype/tymatrix.nim index 7d3d52f85..14c4d8c88 100644 --- a/tests/metatype/tymatrix.nim +++ b/tests/metatype/tymatrix.nim @@ -1,6 +1,6 @@ import typetraits -template reject(e: expr) = +template reject(e) = static: assert(not compiles(e)) type diff --git a/tests/misc/thallo.nim b/tests/misc/thallo.nim index 17e955f03..17e6089ed 100644 --- a/tests/misc/thallo.nim +++ b/tests/misc/thallo.nim @@ -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".} - diff --git a/tests/misc/tints.nim b/tests/misc/tints.nim index 5bfb8a17c..d5374a543 100644 --- a/tests/misc/tints.nim +++ b/tests/misc/tints.nim @@ -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) diff --git a/tests/misc/tsimplesort.nim b/tests/misc/tsimplesort.nim index 9c6ad1207..3115863d5 100644 --- a/tests/misc/tsimplesort.nim +++ b/tests/misc/tsimplesort.nim @@ -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 - - diff --git a/tests/objects/toop1.nim b/tests/objects/toop1.nim index 4727d146d..f4880e3c6 100644 --- a/tests/objects/toop1.nim +++ b/tests/objects/toop1.nim @@ -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) diff --git a/tests/overload/tparams_after_varargs.nim b/tests/overload/tparams_after_varargs.nim index a93e280b9..ad8f19ad3 100644 --- a/tests/overload/tparams_after_varargs.nim +++ b/tests/overload/tparams_after_varargs.nim @@ -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" diff --git a/tests/overload/tspec.nim b/tests/overload/tspec.nim index f2002a390..a84bac244 100644 --- a/tests/overload/tspec.nim +++ b/tests/overload/tspec.nim @@ -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) diff --git a/tests/overload/tstmtoverload.nim b/tests/overload/tstmtoverload.nim index 75584bcab..7c0194e60 100644 --- a/tests/overload/tstmtoverload.nim +++ b/tests/overload/tstmtoverload.nim @@ -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" diff --git a/tests/parallel/tconvexhull.nim b/tests/parallel/tconvexhull.nim index dffe5339b..c4990bf2d 100644 --- a/tests/parallel/tconvexhull.nim +++ b/tests/parallel/tconvexhull.nim @@ -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 diff --git a/tests/parallel/tguard1.nim b/tests/parallel/tguard1.nim index 3e0c131c5..c7972d225 100644 --- a/tests/parallel/tguard1.nim +++ b/tests/parallel/tguard1.nim @@ -24,7 +24,7 @@ var c.i = 89 -template atomicRead(L, x): expr = +template atomicRead(L, x): untyped = {.locks: [L].}: x diff --git a/tests/parallel/tguard2.nim b/tests/parallel/tguard2.nim index b69ea3371..661893bb5 100644 --- a/tests/parallel/tguard2.nim +++ b/tests/parallel/tguard2.nim @@ -13,7 +13,7 @@ var c.i = 89 -template atomicRead(L, x): expr = +template atomicRead(L, x): untyped = {.locks: [L].}: x diff --git a/tests/parallel/tptr_to_ref.nim b/tests/parallel/tptr_to_ref.nim index 229c247ce..fee210dcd 100644 --- a/tests/parallel/tptr_to_ref.nim +++ b/tests/parallel/tptr_to_ref.nim @@ -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].}: diff --git a/tests/parser/toprprec.nim b/tests/parser/toprprec.nim index 2c22f5b80..1acd381e7 100644 --- a/tests/parser/toprprec.nim +++ b/tests/parser/toprprec.nim @@ -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" - - - diff --git a/tests/parser/tstrongspaces.nim b/tests/parser/tstrongspaces.nim index cb0219976..adab7f709 100644 --- a/tests/parser/tstrongspaces.nim +++ b/tests/parser/tstrongspaces.nim @@ -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 diff --git a/tests/pragmas/tsym_as_pragma.nim b/tests/pragmas/tsym_as_pragma.nim index f6ba44dc9..788311244 100644 --- a/tests/pragmas/tsym_as_pragma.nim +++ b/tests/pragmas/tsym_as_pragma.nim @@ -1,7 +1,7 @@ # bug #3171 -template newDataWindow(): stmt = +template newDataWindow(): untyped = let eventClosure = proc (closure: pointer): bool {.closure, cdecl.} = discard diff --git a/tests/range/compilehelpers.nim b/tests/range/compilehelpers.nim index cb26ca5b5..08f97a5bf 100644 --- a/tests/range/compilehelpers.nim +++ b/tests/range/compilehelpers.nim @@ -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)) - diff --git a/tests/showoff/tdrdobbs_examples.nim b/tests/showoff/tdrdobbs_examples.nim index 78f711325..8687ee529 100644 --- a/tests/showoff/tdrdobbs_examples.nim +++ b/tests/showoff/tdrdobbs_examples.nim @@ -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 diff --git a/tests/showoff/tformatopt.nim b/tests/showoff/tformatopt.nim index f33ed6921..6e790c38e 100644 --- a/tests/showoff/tformatopt.nim +++ b/tests/showoff/tformatopt.nim @@ -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) diff --git a/tests/showoff/thtml1.nim b/tests/showoff/thtml1.nim index c7a083c21..fe0cd3b1e 100644 --- a/tests/showoff/thtml1.nim +++ b/tests/showoff/thtml1.nim @@ -2,7 +2,7 @@ discard """ output: "<br>" """ -template htmlTag(tag: expr) {.immediate.} = +template htmlTag(tag: untyped) = proc tag(): string = "<" & astToStr(tag) & ">" htmlTag(br) diff --git a/tests/showoff/thtml2.nim b/tests/showoff/thtml2.nim index faeb4e50d..dcf6534a5 100644 --- a/tests/showoff/thtml2.nim +++ b/tests/showoff/thtml2.nim @@ -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 diff --git a/tests/showoff/tonce.nim b/tests/showoff/tonce.nim index 6fc372e87..ed2684dcf 100644 --- a/tests/showoff/tonce.nim +++ b/tests/showoff/tonce.nim @@ -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 diff --git a/tests/showoff/tquasiquote.nim b/tests/showoff/tquasiquote.nim index ebe004a92..404712a02 100644 --- a/tests/showoff/tquasiquote.nim +++ b/tests/showoff/tquasiquote.nim @@ -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: diff --git a/tests/specialops/tdotops.nim b/tests/specialops/tdotops.nim index ce5b3942d..bca949922 100644 --- a/tests/specialops/tdotops.nim +++ b/tests/specialops/tdotops.nim @@ -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))) - diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim index 6a53a2964..434caa281 100644 --- a/tests/stdlib/tmarshal.nim +++ b/tests/stdlib/tmarshal.nim @@ -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"], diff --git a/tests/stdlib/tnre.nim b/tests/stdlib/tnre.nim index 030319ebf..fabbb69a8 100644 --- a/tests/stdlib/tnre.nim +++ b/tests/stdlib/tnre.nim @@ -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 diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim index ec839e288..e2a5a1715 100644 --- a/tests/stdlib/tpegs.nim +++ b/tests/stdlib/tpegs.nim @@ -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: ## diff --git a/tests/template/annotate.nim b/tests/template/annotate.nim index 5f395557b..a7e2f8fdb 100644 --- a/tests/template/annotate.nim +++ b/tests/template/annotate.nim @@ -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: diff --git a/tests/template/mcan_access_hidden_field.nim b/tests/template/mcan_access_hidden_field.nim index bf3592701..2c0026ec1 100644 --- a/tests/template/mcan_access_hidden_field.nim +++ b/tests/template/mcan_access_hidden_field.nim @@ -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 diff --git a/tests/template/t2do.nim b/tests/template/t2do.nim index ec364c5f3..f5f6393dc 100644 --- a/tests/template/t2do.nim +++ b/tests/template/t2do.nim @@ -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 diff --git a/tests/template/t_otemplates.nim b/tests/template/t_otemplates.nim index 6c419f72f..6597bd37a 100644 --- a/tests/template/t_otemplates.nim +++ b/tests/template/t_otemplates.nim @@ -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 diff --git a/tests/template/tdefault_nil.nim b/tests/template/tdefault_nil.nim index 891166306..c5c372d9e 100644 --- a/tests/template/tdefault_nil.nim +++ b/tests/template/tdefault_nil.nim @@ -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: diff --git a/tests/template/thygienictempl.nim b/tests/template/thygienictempl.nim index 5e4f534f8..de40450aa 100644 --- a/tests/template/thygienictempl.nim +++ b/tests/template/thygienictempl.nim @@ -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 diff --git a/tests/template/tissue909.nim b/tests/template/tissue909.nim index 5b57a3558..6786ff48c 100644 --- a/tests/template/tissue909.nim +++ b/tests/template/tissue909.nim @@ -8,7 +8,7 @@ template baz() = var y = foo discard y() -macro test(): stmt = +macro test(): untyped = result = getAst(baz()) echo(treeRepr(result)) diff --git a/tests/template/tissue993.nim b/tests/template/tissue993.nim index dae9df683..552890bb4 100644 --- a/tests/template/tissue993.nim +++ b/tests/template/tissue993.nim @@ -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) - diff --git a/tests/template/tit.nim b/tests/template/tit.nim index cf50d2f6f..76b1d151b 100644 --- a/tests/template/tit.nim +++ b/tests/template/tit.nim @@ -1,7 +1,7 @@ # bug #1337 -template someIt(a, pred: expr): expr = +template someIt(a, pred): untyped = var it {.inject.} = 0 pred diff --git a/tests/template/tparams_gensymed.nim b/tests/template/tparams_gensymed.nim index 568725fd4..3fb0dd4a5 100644 --- a/tests/template/tparams_gensymed.nim +++ b/tests/template/tparams_gensymed.nim @@ -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 diff --git a/tests/template/tprefer_immediate.nim b/tests/template/tprefer_immediate.nim index 578f447b0..3a4cfc07b 100644 --- a/tests/template/tprefer_immediate.nim +++ b/tests/template/tprefer_immediate.nim @@ -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) - diff --git a/tests/template/tscope.nim b/tests/template/tscope.nim index 2d5841af3..1eeebbdd4 100644 --- a/tests/template/tscope.nim +++ b/tests/template/tscope.nim @@ -3,7 +3,7 @@ discard """ """ var x = 1 -template quantity(): stmt {.immediate.} = +template quantity() = # Causes internal error in compiler/sem.nim proc unit*(x = 1.0): float = 12 # Throws the correct error: redefinition of 'x' diff --git a/tests/template/tstmt_semchecked_twice.nim b/tests/template/tstmt_semchecked_twice.nim index 05c16c3c9..c6463ae06 100644 --- a/tests/template/tstmt_semchecked_twice.nim +++ b/tests/template/tstmt_semchecked_twice.nim @@ -13,7 +13,7 @@ type Vector2[T] = T Pixels=int -template use*(fb: int, st: stmt) : stmt = +template use*(fb: int, st: untyped): untyped = echo "a ", $fb st echo "a ", $fb diff --git a/tests/template/tsymchoicefield.nim b/tests/template/tsymchoicefield.nim index ab05500bf..4483c2aa2 100644 --- a/tests/template/tsymchoicefield.nim +++ b/tests/template/tsymchoicefield.nim @@ -3,10 +3,9 @@ type Foo = object var f = Foo(len: 40) -template getLen(f: Foo): expr = f.len +template getLen(f: Foo): int = f.len echo f.getLen # This fails, because `len` gets the nkOpenSymChoice # treatment inside the template early pass and then # it can't be recognized as a field anymore - diff --git a/tests/template/ttempl3.nim b/tests/template/ttempl3.nim index 56daf9fe6..91d416c48 100644 --- a/tests/template/ttempl3.nim +++ b/tests/template/ttempl3.nim @@ -1,6 +1,6 @@ -template withOpenFile(f: expr, filename: string, mode: TFileMode, - actions: stmt): stmt {.immediate.} = +template withOpenFile(f: untyped, filename: string, mode: TFileMode, + actions: untyped): untyped = block: # test that 'f' is implicitly 'injecting': var f: TFile @@ -20,20 +20,20 @@ var myVar: array[0..1, int] # Test zero argument template: -template ha: expr = myVar[0] +template ha: untyped = myVar[0] ha = 1 echo(ha) # Test identifier generation: -template prefix(name: expr): expr {.immediate.} = `"hu" name` +template prefix(name): untyped = `"hu" name` var `hu "XYZ"` = "yay" echo prefix(XYZ) -template typedef(name: expr, typ: typeDesc) {.immediate, dirty.} = +template typedef(name: untyped, typ: typeDesc) {.immediate, dirty.} = type `T name`* = typ `P name`* = ref `T name` @@ -51,7 +51,7 @@ type proc initFoo(arg: int): Foo = result.arg = arg -template create(typ: typeDesc, arg: expr): expr = `init typ`(arg) +template create(typ: typeDesc, arg: untyped): untyped = `init typ`(arg) var ff = Foo.create(12) diff --git a/tests/template/ttempl4.nim b/tests/template/ttempl4.nim index 26c82e471..d1d26385f 100644 --- a/tests/template/ttempl4.nim +++ b/tests/template/ttempl4.nim @@ -1,8 +1,7 @@ -template `:=`(name, val: expr): stmt {.immediate.} = +template `:=`(name, val: untyped): typed = var name = val ha := 1 * 4 hu := "ta-da" == "ta-da" echo ha, hu - diff --git a/tests/template/ttempl5.nim b/tests/template/ttempl5.nim index a020a8e2c..fd3ea0cad 100644 --- a/tests/template/ttempl5.nim +++ b/tests/template/ttempl5.nim @@ -9,7 +9,7 @@ proc parse_to_close(value: string, index: int, open='(', close=')'): int = discard # Call parse_to_close -template get_next_ident: stmt = +template get_next_ident: typed = discard "{something}".parse_to_close(0, open = '{', close = '}') get_next_ident() @@ -19,11 +19,10 @@ get_next_ident() #bug #880 (also example in the manual!) -template typedef(name: expr, typ: typedesc) {.immediate.} = +template typedef(name: untyped, typ: typedesc) = type `T name`* {.inject.} = typ `P name`* {.inject.} = ref `T name` typedef(myint, int) var x: PMyInt - diff --git a/tests/template/twhen_gensym.nim b/tests/template/twhen_gensym.nim index d84ee6f03..f1a8d0eb7 100644 --- a/tests/template/twhen_gensym.nim +++ b/tests/template/twhen_gensym.nim @@ -3,7 +3,7 @@ discard """ """ # bug #2670 -template testTemplate(b: bool): stmt = +template testTemplate(b: bool): typed = when b: var a = "hi" else: diff --git a/tests/template/twrongmapit.nim b/tests/template/twrongmapit.nim index df695fcd6..cbc63b9cd 100644 --- a/tests/template/twrongmapit.nim +++ b/tests/template/twrongmapit.nim @@ -8,7 +8,7 @@ discard """ type Foo* {.pure, final.} = object elt: float -template defineOpAssign(T: expr, op: expr) {.immediate.} = +template defineOpAssign(T, op: untyped) {.immediate.} = proc op*(v: var T, w: T) {.inline.} = for i in 0..1: op(v.elt, w.elt) @@ -18,7 +18,7 @@ const ATTEMPT = 0 when ATTEMPT == 0: # FAILS: defining `/=` with template calling template # ERROR about sem.nim line 144 - template defineOpAssigns(T: expr) {.immediate.} = + template defineOpAssigns(T: untyped) = mixin `/=` defineOpAssign(T, `/=`) diff --git a/tests/template/twrongsymkind.nim b/tests/template/twrongsymkind.nim index be3d8c652..5fa618914 100644 --- a/tests/template/twrongsymkind.nim +++ b/tests/template/twrongsymkind.nim @@ -9,7 +9,7 @@ type MyData = object x: int -template newDataWindow(data: ref MyData): stmt = +template newDataWindow(data: ref MyData): untyped = proc testProc(data: ref MyData) = echo "Hello, ", data.x testProc(data) diff --git a/tests/template/utemplates.nim b/tests/template/utemplates.nim index 8b9ae5d26..199268046 100644 --- a/tests/template/utemplates.nim +++ b/tests/template/utemplates.nim @@ -1,32 +1,31 @@ import unittest -template t(a: int): expr = "int" -template t(a: string): expr = "string" +template t(a: int): string = "int" +template t(a: string): string = "string" test "templates can be overloaded": check t(10) == "int" check t("test") == "string" test "previous definitions can be further overloaded or hidden in local scopes": - template t(a: bool): expr = "bool" + template t(a: bool): string = "bool" check t(true) == "bool" check t(10) == "int" - template t(a: int): expr = "inner int" + template t(a: int): string = "inner int" check t(10) == "inner int" check t("test") == "string" test "templates can be redefined multiple times": - template customAssert(cond: bool, msg: string): stmt {.immediate, dirty.} = + template customAssert(cond: bool, msg: string): typed {.immediate, dirty.} = if not cond: fail(msg) - template assertion_failed(body: stmt) {.immediate, dirty.} = - template fail(msg: string): stmt = body + template assertion_failed(body: typed) {.immediate, dirty.} = + template fail(msg: string): typed = body assertion_failed: check msg == "first fail path" customAssert false, "first fail path" assertion_failed: check msg == "second fail path" customAssert false, "second fail path" - diff --git a/tests/trmacros/targlist.nim b/tests/trmacros/targlist.nim index f9d2cb6c6..46235dab1 100644 --- a/tests/trmacros/targlist.nim +++ b/tests/trmacros/targlist.nim @@ -3,7 +3,7 @@ discard """ """ proc f(x: varargs[string, `$`]) = discard -template optF{f(x)}(x: varargs[expr]) = +template optF{f(x)}(x: varargs[untyped]) = writeLine(stdout, x) f 1, 2, false, 3, "ha" diff --git a/tests/trmacros/tcse.nim b/tests/trmacros/tcse.nim index 023a8f298..315570d8f 100644 --- a/tests/trmacros/tcse.nim +++ b/tests/trmacros/tcse.nim @@ -2,8 +2,8 @@ discard """ output: "4" """ -template cse{f(a, a, x)}(a: expr{(nkDotExpr|call|nkBracketExpr)&noSideEffect}, - f: expr, x: varargs[expr]): expr = +template cse{f(a, a, x)}(a: typed{(nkDotExpr|call|nkBracketExpr)&noSideEffect}, + f: typed, x: varargs[typed]): untyped = let aa = a f(aa, aa, x)+4 diff --git a/tests/trmacros/tmatrix.nim b/tests/trmacros/tmatrix.nim index f409434c5..a14ad2db0 100644 --- a/tests/trmacros/tmatrix.nim +++ b/tests/trmacros/tmatrix.nim @@ -15,7 +15,7 @@ proc `$`(a: TMat): string = result = $a.dummy proc mat21(): TMat = result.dummy = 21 -macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): expr = +macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): untyped = echo treeRepr(a) result = newCall(bindSym"mat21") diff --git a/tests/trmacros/tnoalias.nim b/tests/trmacros/tnoalias.nim index 1d5671362..ec12d4712 100644 --- a/tests/trmacros/tnoalias.nim +++ b/tests/trmacros/tnoalias.nim @@ -2,7 +2,7 @@ discard """ output: "23" """ -template optslice{a = b + c}(a: expr{noalias}, b, c: expr): stmt = +template optslice{a = b + c}(a: untyped{noalias}, b, c: untyped): typed = a = b inc a, c diff --git a/tests/trmacros/tnoalias2.nim b/tests/trmacros/tnoalias2.nim index 5a816acb9..9362e764f 100644 --- a/tests/trmacros/tnoalias2.nim +++ b/tests/trmacros/tnoalias2.nim @@ -3,7 +3,7 @@ discard """ """ # bug #206 -template optimizeOut{testFunc(a, b)}(a: int, b: int{alias}) : expr = 0 +template optimizeOut{testFunc(a, b)}(a: int, b: int{alias}): untyped = 0 proc testFunc(a, b: int): int = result = a + b var testVar = 1 diff --git a/tests/trmacros/tnoendlessrec.nim b/tests/trmacros/tnoendlessrec.nim index 53891bcc0..508770ca7 100644 --- a/tests/trmacros/tnoendlessrec.nim +++ b/tests/trmacros/tnoendlessrec.nim @@ -4,7 +4,7 @@ discard """ # test that an endless recursion is avoided: -template optLen{len(x)}(x: expr): expr = len(x) +template optLen{len(x)}(x: typed): int = len(x) var s = "lala" echo len(s) diff --git a/tests/trmacros/tor.nim b/tests/trmacros/tor.nim index 500851582..d698e928d 100644 --- a/tests/trmacros/tor.nim +++ b/tests/trmacros/tor.nim @@ -4,13 +4,13 @@ true 3''' """ -template arithOps: expr = (`+` | `-` | `*`) -template testOr{ (arithOps{f})(a, b) }(a, b, f: expr): expr = f(a+1, b) +template arithOps: untyped = (`+` | `-` | `*`) +template testOr{ (arithOps{f})(a, b) }(a, b, f: untyped): untyped = f(a+1, b) let xx = 10 echo 10*xx -template t{x = (~x){y} and (~x){z}}(x, y, z: bool): stmt = +template t{x = (~x){y} and (~x){z}}(x, y, z: bool): typed = x = y if x: x = z @@ -22,7 +22,7 @@ a = b and a echo a # bug #798 -template t012{(0|1|2){x}}(x: expr): expr = x+1 +template t012{(0|1|2){x}}(x: untyped): untyped = x+1 let z = 1 # outputs 3 thanks to fixpoint iteration: echo z diff --git a/tests/trmacros/tpartial.nim b/tests/trmacros/tpartial.nim index fdaa3414a..c636684d7 100644 --- a/tests/trmacros/tpartial.nim +++ b/tests/trmacros/tpartial.nim @@ -5,7 +5,7 @@ discard """ proc p(x, y: int; cond: bool): int = result = if cond: x + y else: x - y -template optP{p(x, y, true)}(x, y: expr): expr = x - y -template optP{p(x, y, false)}(x, y: expr): expr = x + y +template optP{p(x, y, true)}(x, y): untyped = x - y +template optP{p(x, y, false)}(x, y): untyped = x + y echo p(2, 4, true) diff --git a/tests/trmacros/tstar.nim b/tests/trmacros/tstar.nim index 536289ff0..86f698232 100644 --- a/tests/trmacros/tstar.nim +++ b/tests/trmacros/tstar.nim @@ -10,7 +10,7 @@ proc `&&`(s: varargs[string]): string = for i in 1..len(s)-1: result.add s[i] inc calls -template optConc{ `&&` * a }(a: string): expr = &&a +template optConc{ `&&` * a }(a: string): string = &&a let space = " " echo "my" && (space & "awe" && "some " ) && "concat" diff --git a/tests/trmacros/tstmtlist.nim b/tests/trmacros/tstmtlist.nim index 5202f778b..751acb79a 100644 --- a/tests/trmacros/tstmtlist.nim +++ b/tests/trmacros/tstmtlist.nim @@ -8,7 +8,7 @@ discard """ template optWrite{ write(f, x) ((write|writeLine){w})(f, y) -}(x, y: varargs[expr], f, w: expr) = +}(x, y: varargs[untyped], f, w: untyped) = w(f, "|", x, y, "|") if true: diff --git a/tests/tuples/tuple_with_nil.nim b/tests/tuples/tuple_with_nil.nim index 9b5d583d3..7f5a359f5 100644 --- a/tests/tuples/tuple_with_nil.nim +++ b/tests/tuples/tuple_with_nil.nim @@ -758,7 +758,7 @@ proc addfmtfmt(fmtstr: string; args: NimNode; retvar: NimNode): NimNode {.compil if arg.cnt == 0: warning("Argument " & $(i+1) & " `" & args[i].repr & "` is not used in format string") -macro addfmt(s: var string, fmtstr: string{lit}, args: varargs[expr]): expr = +macro addfmt(s: var string, fmtstr: string{lit}, args: varargs[typed]): untyped = ## The same as `s.add(fmtstr.fmt(args...))` but faster. result = addfmtfmt($fmtstr, args, s) diff --git a/tests/typerel/temptynode.nim b/tests/typerel/temptynode.nim index b32b16121..32148ce13 100644 --- a/tests/typerel/temptynode.nim +++ b/tests/typerel/temptynode.nim @@ -10,7 +10,7 @@ import macros proc blah(x: proc (a, b: int): int) = echo x(5, 5) -macro test(): stmt = +macro test(): untyped = result = newNimNode(nnkEmpty) blah(test()) diff --git a/tests/typerel/tsymchoice_for_expr.nim b/tests/typerel/tsymchoice_for_expr.nim index 4c1f52bef..394b22704 100644 --- a/tests/typerel/tsymchoice_for_expr.nim +++ b/tests/typerel/tsymchoice_for_expr.nim @@ -1,6 +1,6 @@ # bug #1988 -template t(e: expr) = discard +template t(e) = discard proc positive(x: int): int = +x proc negative(x: int): int = -x diff --git a/tests/typerel/tvarargsexpr.nim b/tests/typerel/tvarargsexpr.nim index c6a59fb20..092d50076 100644 --- a/tests/typerel/tvarargsexpr.nim +++ b/tests/typerel/tvarargsexpr.nim @@ -8,7 +8,7 @@ true''' import macros -macro thirteen(args: varargs[expr]): expr = +macro thirteen(args: varargs[untyped]): int = result = newIntLitNode(13) doAssert(13==thirteen([1,2])) # works @@ -22,7 +22,8 @@ echo "success" # bug #2545 import macros -macro test(e: varargs[untyped]): expr = bindSym"true" +macro test(e: varargs[untyped]): untyped = + bindSym"true" echo test(a) echo test(fake=90, arguments=80, also="false", possible=true) diff --git a/tests/types/tauto_canbe_void.nim b/tests/types/tauto_canbe_void.nim index 60e83c510..fd42cb701 100644 --- a/tests/types/tauto_canbe_void.nim +++ b/tests/types/tauto_canbe_void.nim @@ -1,7 +1,7 @@ import future -template tempo(s: expr) = +template tempo(s) = s("arg") tempo((s: string)->auto => echo(s)) diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim index 14999ebee..2f9dbf245 100644 --- a/tests/types/tisopr.nim +++ b/tests/types/tisopr.nim @@ -17,10 +17,10 @@ proc IsVoid[T](): string = const x = int is int echo x, " ", float is float, " ", float is string, " ", IsVoid[void]() -template yes(e: expr): stmt = +template yes(e): void = static: assert e -template no(e: expr): stmt = +template no(e): void = static: assert(not e) when false: diff --git a/tests/usingstmt/tusingstatement.nim b/tests/usingstmt/tusingstatement.nim index 0d76b2423..8585bcc9e 100644 --- a/tests/usingstmt/tusingstatement.nim +++ b/tests/usingstmt/tusingstatement.nim @@ -12,7 +12,7 @@ import # Nim's destructors offer a mechanism for automatic # disposal of resources. # -macro autoClose(e: expr): stmt {.immediate.} = +macro autoClose(args: varargs[untyped]): untyped = let e = callsite() if e.len != 3: error "Using statement: unexpected number of arguments. Got " & @@ -85,5 +85,3 @@ proc use(r: var TResource) = autoClose(r = openResource("test")): use r - - diff --git a/tests/vm/tanonproc.nim b/tests/vm/tanonproc.nim index 474b768ca..c5cb57d75 100644 --- a/tests/vm/tanonproc.nim +++ b/tests/vm/tanonproc.nim @@ -42,7 +42,7 @@ proc getOrElse[T](o: Option[T], def: T): T = proc quoteStr(s: string): Option[string] = s.some.notEmpty.map(v => "`" & v & "`") -macro str(s: string): stmt = +macro str(s: string): typed = let x = s.strVal let y = quoteStr(x) let sn = newStrLitNode(y.getOrElse("NONE")) diff --git a/tests/vm/tasmparser.nim b/tests/vm/tasmparser.nim index fbacdbc87..d70c629b6 100644 --- a/tests/vm/tasmparser.nim +++ b/tests/vm/tasmparser.nim @@ -10,10 +10,10 @@ var cpp {.compileTime.} = "" token {.compileTime.} = "" -proc log (msg: string) {.compileTime.} = +proc log(msg: string) {.compileTime.} = echo msg -proc asmx64 () {.compileTime} = +proc asmx64() {.compileTime} = #log "code = $1" % code @@ -36,7 +36,7 @@ proc asmx64 () {.compileTime} = const end_or_symbol_or_comment_or_passthrough = symbolStart + end_or_comment + passthrough_start - proc abortAsmParse (err:string) = + proc abortAsmParse(err:string) = discard let codeLen = code.len @@ -49,17 +49,17 @@ proc asmx64 () {.compileTime} = var state:asmParseState = leading - proc checkEnd (err:string) = - let ch = code [start] - if int (ch) == 0: - abortAsmParse (err) + proc checkEnd(err:string) = + let ch = code[start] + if int(ch) == 0: + abortAsmParse(err) - proc get_passthrough () = + proc get_passthrough() = inc start let prev_start = start let prev_token = token - start += code.parseUntil (token, passthrough_end, start) - checkEnd ("Failed to find passthrough end delimiter from offset $1 for:$2\n$3" % [$prev_start, $(code [prev_start-prev_token.len..prev_start]), token[1..token.len-1]]) + start += code.parseUntil(token, passthrough_end, start) + checkEnd("Failed to find passthrough end delimiter from offset $1 for:$2\n$3" % [$prev_start, $(code[prev_start-prev_token.len..prev_start]), token[1..token.len-1]]) inc start cpp.add "`" cpp.add token @@ -67,27 +67,27 @@ proc asmx64 () {.compileTime} = var inparse = true - proc checkCmdEnd () = + proc checkCmdEnd() = if codeLen == start: state = endCmd inparse = false while inparse: - checkCmdEnd () + checkCmdEnd() - log ("state=$1 start=$2" % [$state, $start]) + log("state=$1 start=$2" % [$state, $start]) case state: of leading: echo "b100 ", start - start += code.skipWhile (leadingWhiteSpace, start) + start += code.skipWhile(leadingWhiteSpace, start) echo "b200 ", start - let ch = code [start] + let ch = code[start] if ch in endOfLine: - inc (line) + inc(line) #echo "c100 ", start, ' ', code - start += code.skipWhile (endOfline, start) + start += code.skipWhile(endOfline, start) #echo "c200 ", start, ' ', code continue elif ch in symbolStart: @@ -95,20 +95,20 @@ proc asmx64 () {.compileTime} = elif ch in eolComment: state = skipToEndOfLine elif ch in passthrough_start: - get_passthrough () + get_passthrough() echo "d100 ", start - start += code.parseUntil (token, end_or_symbol_or_comment_or_passthrough, start) + start += code.parseUntil(token, end_or_symbol_or_comment_or_passthrough, start) echo "d200 ", start cpp.add token state = mnemonic - elif int (ch) == 0: + elif int(ch) == 0: break else: - abortAsmParse ("after '$3' illegal character at offset $1: $2" % [$start, $(int (ch)), token]) + abortAsmParse("after '$3' illegal character at offset $1: $2" % [$start, $(int(ch)), token]) of mnemonic: echo "e100 ", start - start += code.parseWhile (token, symbol, start) + start += code.parseWhile(token, symbol, start) echo "e200 ", start cpp.add xp cpp.add token @@ -118,29 +118,29 @@ proc asmx64 () {.compileTime} = of betweenArguments: let tmp = start let rcode = code - start += rcode.parseUntil (token, end_or_symbol_or_comment_or_passthrough, tmp) + start += rcode.parseUntil(token, end_or_symbol_or_comment_or_passthrough, tmp) cpp.add token if codeLen <= start: state = endCmd continue - let ch = code [start] + let ch = code[start] if ch in passthrough_start: - get_passthrough () + get_passthrough() continue - if (ch in {'x', 'X'}) and ('0' == code [start-1]): - token = $(code [start]) + if(ch in {'x', 'X'}) and('0' == code[start-1]): + token = $(code[start]) cpp.add token inc start continue state = arguments of arguments: - if code [start] in end_or_comment: + if code[start] in end_or_comment: state = endCmd continue - start += code.parseWhile (token, symbol, start) + start += code.parseWhile(token, symbol, start) cpp.add xp cpp.add token state = betweenArguments @@ -151,21 +151,21 @@ proc asmx64 () {.compileTime} = of skipToEndOfLine: echo "a100 ", start - start += code.skipUntil (endOfLine, start) + start += code.skipUntil(endOfLine, start) echo "a200 ", start - start += code.skipWhile (endOfline, start) + start += code.skipWhile(endOfline, start) echo "a300 ", start inc line state = leading cpp.add asmx64post - echo ($cpp) + echo($cpp) -macro asmx64x (code_in:expr) : stmt = +macro asmx64x(code_in:untyped) : typed = code = $code_in - echo ("code.len = $1, code = >>>$2<<<" % [$code.len, code]) - asmx64 () + echo("code.len = $1, code = >>>$2<<<" % [$code.len, code]) + asmx64() discard result asmx64x """ diff --git a/tests/vm/tcomponent.nim b/tests/vm/tcomponent.nim index efeba2a6d..e7962e7ab 100644 --- a/tests/vm/tcomponent.nim +++ b/tests/vm/tcomponent.nim @@ -70,12 +70,12 @@ proc parse_component(body: NimNode): Component = result.procs_index.add(procdef.identifier.name) else: discard -macro component*(name: expr, body: stmt): stmt {.immediate.} = +macro component*(name, body: untyped): typed = let component = parse_component(body) registry.addComponent($name, component) parseStmt("discard") -macro component_builtins(body: stmt): stmt {.immediate.} = +macro component_builtins(body: untyped): typed = let builtin = parse_component(body) registry.field_index = builtin.field_index registry.procs_index = builtin.procs_index @@ -88,7 +88,7 @@ proc bind_methods*(component: var Component, identifier: Ident): seq[NimNode] = procdef.params.insert(this_field, 0) result.add(procdef.render()) -macro bind_components*(type_name, component_names: expr): stmt {.immediate.} = +macro bind_components*(type_name, component_names: untyped): typed = result = newStmtList() let identifier = newIdent(type_name) let components = newBracket(component_names) diff --git a/tests/vm/teval1.nim b/tests/vm/teval1.nim index 1d3a68a0d..0eaa050da 100644 --- a/tests/vm/teval1.nim +++ b/tests/vm/teval1.nim @@ -5,7 +5,7 @@ proc testProc: string {.compileTime.} = result = result & "" when true: - macro test(n: stmt): stmt {.immediate.} = + macro test(n: untyped): untyped = result = newNimNode(nnkStmtList) echo "#", testProc(), "#" test: @@ -20,5 +20,3 @@ echo "##", x, "##" static: var i, j: set[int8] = {} var k = i + j - - diff --git a/tests/vm/texcl.nim b/tests/vm/texcl.nim index 4ccfd6bfa..e23a423fe 100644 --- a/tests/vm/texcl.nim +++ b/tests/vm/texcl.nim @@ -15,13 +15,13 @@ proc initOpts(): set[nlOptions] = result.incl nloDebug result.incl nloNone result.excl nloDebug - + const cOpts = initOpts() -macro nlo(): stmt = +macro nlo(): typed = nlOpts.incl(nloNone) nlOpts.excl(nloDebug) result = newEmptyNode() nlo() -echo nloDebug in cOpts \ No newline at end of file +echo nloDebug in cOpts diff --git a/tests/vm/tmitems.nim b/tests/vm/tmitems.nim index 4ee225eed..a77c3fb23 100644 --- a/tests/vm/tmitems.nim +++ b/tests/vm/tmitems.nim @@ -7,7 +7,7 @@ discard """ # bug #3731 var list {.compileTime.} = newSeq[int]() -macro calc*(): stmt {.immediate.} = +macro calc*(): typed = list.add(1) for c in list.mitems: c = 13 @@ -19,7 +19,7 @@ calc() # bug #3859 import macros -macro m: stmt = +macro m: typed = var s = newseq[NimNode](3) # var s: array[3,NimNode] # not working either for i in 0..<s.len: s[i] = newLit(3) # works diff --git a/tests/vm/tstaticprintseq.nim b/tests/vm/tstaticprintseq.nim index e4a6aa081..246a0211b 100644 --- a/tests/vm/tstaticprintseq.nim +++ b/tests/vm/tstaticprintseq.nim @@ -24,7 +24,7 @@ bb const s = @[1,2,3] -macro foo: stmt = +macro foo: typed = for e in s: echo e @@ -34,7 +34,7 @@ static: for e in s: echo e -macro bar(x: static[seq[int]]): stmt = +macro bar(x: static[seq[int]]): untyped = for e in x: echo e @@ -55,7 +55,7 @@ static: var m2: TData = data for x in m2.numbers: echo x -macro ff(d: static[TData]): stmt = +macro ff(d: static[TData]): typed = for x in d.letters: echo x diff --git a/tests/vm/tstringnil.nim b/tests/vm/tstringnil.nim index bb546b698..39e4040dc 100644 --- a/tests/vm/tstringnil.nim +++ b/tests/vm/tstringnil.nim @@ -41,7 +41,7 @@ proc buildSuiteContents(suiteName, suiteDesc, suiteBloc: NimNode): tuple[tests: return (tests: tests) -macro suite(suiteName, suiteDesc: expr, suiteBloc: stmt): stmt {.immediate.} = +macro suite(suiteName, suiteDesc, suiteBloc: untyped): typed = let contents = buildSuiteContents(suiteName, suiteDesc, suiteBloc) # Test above diff --git a/tests/vm/ttouintconv.nim b/tests/vm/ttouintconv.nim index cd25ffb00..5f8884e80 100644 --- a/tests/vm/ttouintconv.nim +++ b/tests/vm/ttouintconv.nim @@ -20,7 +20,7 @@ msg: ''' #bug #2514 -macro foo(): stmt = +macro foo(): typed = var x = 8'u8 var y = 9'u16 var z = 17'u32 @@ -57,21 +57,21 @@ macro foo(): stmt = var zz = 0x7FFFFFFF'u32 echo zz - -macro foo2(): stmt = + +macro foo2(): typed = var xx = 0x7FFFFFFFFFFFFFFF echo xx - + var yy = 0 echo yy - + var zz = 0x80'u8 echo zz - + var ww = -9 var vv = ww.uint var kk = vv.uint32 echo kk - + foo() foo2() diff --git a/tests/vm/twrongconst.nim b/tests/vm/twrongconst.nim index 424ed080e..a329cb578 100644 --- a/tests/vm/twrongconst.nim +++ b/tests/vm/twrongconst.nim @@ -4,6 +4,6 @@ discard """ """ var x: array[100, char] -template foo : expr = x[42] +template foo : char = x[42] const myConst = foo |