avoid asArray macros import when using nimscript
This commit is contained in:
parent
5dfbeab65f
commit
70f3226836
1 changed files with 25 additions and 25 deletions
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
include "system/inclrtl"
|
include "system/inclrtl"
|
||||||
|
|
||||||
import macros
|
|
||||||
|
|
||||||
when not defined(nimhygiene):
|
when not defined(nimhygiene):
|
||||||
{.pragma: dirty.}
|
{.pragma: dirty.}
|
||||||
|
|
||||||
|
|
@ -706,7 +704,9 @@ template newSeqWith*(len: int, init: untyped): untyped =
|
||||||
result[i] = init
|
result[i] = init
|
||||||
result
|
result
|
||||||
|
|
||||||
macro asArray*(values: typed, targetType: typedesc): untyped =
|
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
|
## converts a static array to an array of type ``targetType`` by converting
|
||||||
## each value in the array to the specified type.
|
## each value in the array to the specified type.
|
||||||
##
|
##
|
||||||
|
|
@ -1017,7 +1017,7 @@ when isMainModule:
|
||||||
seq2D[0][1] = true
|
seq2D[0][1] = true
|
||||||
doAssert seq2D == @[@[true, true], @[true, false], @[false, false], @[false, false]]
|
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)
|
let x = asArray([1.2, 2.3, 3.4, 4.5], int)
|
||||||
doAssert x is array[4, int]
|
doAssert x is array[4, int]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue