summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorFredrik Høisæther Rasch <fredrik.h.rasch@uit.no>2017-10-31 12:33:35 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-11-18 14:18:00 +0100
commit70f322683607cbee49f584107cf4af6f0ebbd51e (patch)
tree94f32c351031d809fe07948359035b6885462268 /lib
parent5dfbeab65f6ba16afed58111b4276244cb1e8d34 (diff)
downloadNim-70f322683607cbee49f584107cf4af6f0ebbd51e.tar.gz
avoid asArray macros import when using nimscript
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/collections/sequtils.nim50
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim
index 6041f8268..069be9398 100644
--- a/lib/pure/collections/sequtils.nim
+++ b/lib/pure/collections/sequtils.nim
@@ -20,8 +20,6 @@
 
 include "system/inclrtl"
 
-import macros
-
 when not defined(nimhygiene):
   {.pragma: dirty.}
 
@@ -706,28 +704,30 @@ template newSeqWith*(len: int, init: untyped): untyped =
     result[i] = init
   result
 
-macro asArray*(values: typed, targetType: typedesc): untyped =
-  ## converts a static array to an array of type ``targetType`` by converting
-  ## each value in the array to the specified type.
-  ##
-  ## Example:
-  ##
-  ## .. code-block::
-  ##   let x = asArray([0.1, 1.2, 2.3, 3.4], int)
-  ##   doAssert x is array[4, int]
-  ##
-  ## Short notation for:
-  ##
-  ## .. code-block::
-  ##   let x = [(0.1).int, (1.2).int, (2.3).int, (3.4).int]
-  let tNode = getType(targetType)[1]
-  values.expectKind(nnkBracket)
-  result = newNimNode(nnkBracket, lineInfoFrom=values)
-  for i in 0 ..< len(values):
-    var dot = newNimNode(nnkDotExpr, lineInfoFrom=values[i])
-    dot.add newPar(values[i])
-    dot.add tNode
-    result.add dot
+when not defined(nimscript):
+  import macros
+  macro asArray*(values: typed, targetType: typedesc): untyped =
+    ## converts a static array to an array of type ``targetType`` by converting
+    ## each value in the array to the specified type.
+    ##
+    ## Example:
+    ##
+    ## .. code-block::
+    ##   let x = asArray([0.1, 1.2, 2.3, 3.4], int)
+    ##   doAssert x is array[4, int]
+    ##
+    ## Short notation for:
+    ##
+    ## .. code-block::
+    ##   let x = [(0.1).int, (1.2).int, (2.3).int, (3.4).int]
+    let tNode = getType(targetType)[1]
+    values.expectKind(nnkBracket)
+    result = newNimNode(nnkBracket, lineInfoFrom=values)
+    for i in 0 ..< len(values):
+      var dot = newNimNode(nnkDotExpr, lineInfoFrom=values[i])
+      dot.add newPar(values[i])
+      dot.add tNode
+      result.add dot
 
 when isMainModule:
   import strutils
@@ -1017,7 +1017,7 @@ when isMainModule:
     seq2D[0][1] = true
     doAssert seq2D == @[@[true, true], @[true, false], @[false, false], @[false, false]]
 
-  block: # asArray tests
+  when not defined(nimscript): # asArray tests
     let x = asArray([1.2, 2.3, 3.4, 4.5], int)
     doAssert x is array[4, int]