summary refs log tree commit diff stats
path: root/tests/vm
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-06-26 23:16:40 +0200
committerGitHub <noreply@github.com>2018-06-26 23:16:40 +0200
commitccb15148370f78768c6a5655f2b09d8ab9e85768 (patch)
treec50eff36ca3b315024ff43fc2f0741e414cc2e52 /tests/vm
parentbf5de98c6a68c73fb9a5e638b3877e5ef4674791 (diff)
parentf559e62e45b4be227d494e75fe82f571ee410840 (diff)
downloadNim-ccb15148370f78768c6a5655f2b09d8ab9e85768.tar.gz
Merge pull request #8108 from LemonBoy/fix-5958
Make `static` blocks introduce their own scope
Diffstat (limited to 'tests/vm')
-rw-r--r--tests/vm/tnimnode.nim20
-rw-r--r--tests/vm/tvmmisc.nim4
2 files changed, 11 insertions, 13 deletions
diff --git a/tests/vm/tnimnode.nim b/tests/vm/tnimnode.nim
index 188bac9bf..4210ab41d 100644
--- a/tests/vm/tnimnode.nim
+++ b/tests/vm/tnimnode.nim
@@ -4,14 +4,12 @@ proc assertEq(arg0,arg1: string): void =
   if arg0 != arg1:
     raiseAssert("strings not equal:\n" & arg0 & "\n" & arg1)
 
-static:
-  # a simple assignment of stmtList to another variable
-  var node: NimNode
-  # an assignment of stmtList into an array
-  var nodeArray: array[1, NimNode]
-  # an assignment of stmtList into a seq
-  var nodeSeq = newSeq[NimNode](2)
-
+# a simple assignment of stmtList to another variable
+var node {.compileTime.}: NimNode
+# an assignment of stmtList into an array
+var nodeArray {.compileTime.}: array[1, NimNode]
+# an assignment of stmtList into a seq
+var nodeSeq {.compileTime.} = newSeq[NimNode](2)
 
 proc checkNode(arg: NimNode; name: string): void {. compileTime .} =
   echo "checking ", name
@@ -35,10 +33,10 @@ proc checkNode(arg: NimNode; name: string): void {. compileTime .} =
 
   echo "OK"
 
-static:
-  # the root node that is used to generate the Ast
-  var stmtList: NimNode
+# the root node that is used to generate the Ast
+var stmtList {.compileTime.}: NimNode
 
+static:
   stmtList = newStmtList(nnkDiscardStmt.newTree(newEmptyNode()))
 
   checkNode(stmtList, "direct construction")
diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim
index 4af824cf4..80f5aeee0 100644
--- a/tests/vm/tvmmisc.nim
+++ b/tests/vm/tvmmisc.nim
@@ -19,9 +19,9 @@ block:
     var x = default(type(0))
 
 # #6379
-static:
-  import algorithm
+import algorithm
 
+static:
   var numArray = [1, 2, 3, 4, -1]
   numArray.sort(cmp)
   assert numArray == [-1, 1, 2, 3, 4]