summary refs log tree commit diff stats
path: root/tests/template
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2017-07-25 09:28:23 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-07-25 09:28:23 +0200
commit000b8afd26fa16684a116d9afe798ea94df9c270 (patch)
treee5295df748b90c5027e44adfa3a442031534572c /tests/template
parent52ff244d5d2775fa4d13f4e2b9a996f411281312 (diff)
downloadNim-000b8afd26fa16684a116d9afe798ea94df9c270.tar.gz
Remove expr/stmt (#5857)
Diffstat (limited to 'tests/template')
-rw-r--r--tests/template/annotate.nim2
-rw-r--r--tests/template/mcan_access_hidden_field.nim3
-rw-r--r--tests/template/t2do.nim2
-rw-r--r--tests/template/t_otemplates.nim8
-rw-r--r--tests/template/tdefault_nil.nim2
-rw-r--r--tests/template/thygienictempl.nim4
-rw-r--r--tests/template/tissue909.nim2
-rw-r--r--tests/template/tissue993.nim7
-rw-r--r--tests/template/tit.nim2
-rw-r--r--tests/template/tparams_gensymed.nim2
-rw-r--r--tests/template/tprefer_immediate.nim6
-rw-r--r--tests/template/tscope.nim2
-rw-r--r--tests/template/tstmt_semchecked_twice.nim2
-rw-r--r--tests/template/tsymchoicefield.nim3
-rw-r--r--tests/template/ttempl3.nim12
-rw-r--r--tests/template/ttempl4.nim3
-rw-r--r--tests/template/ttempl5.nim5
-rw-r--r--tests/template/twhen_gensym.nim2
-rw-r--r--tests/template/twrongmapit.nim4
-rw-r--r--tests/template/twrongsymkind.nim2
-rw-r--r--tests/template/utemplates.nim15
21 files changed, 41 insertions, 49 deletions
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"
-