summary refs log tree commit diff stats
path: root/tests/reject/texprstmt.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/reject/texprstmt.nim')
-rw-r--r--tests/reject/texprstmt.nim12
1 files changed, 0 insertions, 12 deletions
diff --git a/tests/reject/texprstmt.nim b/tests/reject/texprstmt.nim
deleted file mode 100644
index b32394d8d..000000000
--- a/tests/reject/texprstmt.nim
+++ /dev/null
@@ -1,12 +0,0 @@
-discard """
-  line: 10
-  errormsg: "value returned by statement has to be discarded"
-"""
-
-# bug #578
-
-proc test: string =
-  result = "blah"
-  result[1 .. -1]
-
-echo test()
f='/ahoang/Nim/blame/tests/accept/run/tmacros1.nim?h=devel&id=4e7a22cac31a0a703c080c7fe0d2569f56ab16a0'>^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
           
                                  




                  
                                                 
                    























                                                                        
discard """
  output: "Got: 'nnkMacroStmt' hi"
"""

import
  macros, strutils

macro outterMacro*(n: stmt): stmt {.immediate.} =
  let n = callsite()
  var j : string = "hi"
  proc innerProc(i: int): string =
    echo "Using arg ! " & n.repr
    result = "Got: '" & $n.kind & "' " & $j
  if n.kind != TNimrodNodeKind.nnkMacroStmt:
    error("Macro " & n[0].repr & " requires a block.")
  var callNode = n[0]
  expectKind(callNode, TNimrodNodeKind.nnkCall)
  if callNode.len != 2 or callNode[1].kind != TNimrodNodeKind.nnkIdent:
    error("Macro " & callNode.repr &
      " requires the ident passed as parameter (eg: " & callNode.repr & 
      "(the_name_you_want)): statements.")
  result = newNimNode(TNimrodNodeKind.nnkStmtList)
  var ass : PNimrodNode = newNimNode(TNimrodNodeKind.nnkAsgn)
  ass.add(newIdentNode(callNode[1].ident))
  ass.add(newStrLitNode(innerProc(4)))
  result.add(ass)

var str: string
outterMacro(str):
  "hellow"
echo str