This commit is contained in:
Andreas Rumpf
2017-02-04 21:00:07 +01:00
parent 95d8558f0c
commit abaf5d0bdb
5 changed files with 42 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
template mathPerComponent(op: untyped): untyped =
proc op*[N,T](v,u: array[N,T]): array[N,T] {.inline.} =
for i in 0 ..< len(result):
result[i] = `*`(v[i], u[i])
mathPerComponent(`***`)
# bug #5285
when true:
if isMainModule:
var v1: array[3, float64]
var v2: array[3, float64]
echo repr(v1 *** v2)
proc foo(): void =
var v1: array[4, float64]
var v2: array[4, float64]
echo repr(v1 *** v2)
foo()

View File

@@ -6,7 +6,7 @@ discard """
var i {.compileTime.} = 2
template defineId*(t: typedesc): stmt =
template defineId*(t: typedesc) =
const id {.genSym.} = i
static: inc(i)
proc idFor*(T: typedesc[t]): int {.inline, raises: [].} = id