diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-01-16 23:04:45 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-01-16 23:04:53 +0100 |
commit | 54a6c5b34844322f2bb50222cb779dde02c6cad4 (patch) | |
tree | 59e04ac016429193ba276e4f767819e7fdd6598a | |
parent | 915cc86f5d022e2a2eb3bbe03e3e3ec1c9e3e60a (diff) | |
download | Nim-54a6c5b34844322f2bb50222cb779dde02c6cad4.tar.gz |
fixes #5218
-rw-r--r-- | compiler/sighashes.nim | 2 | ||||
-rw-r--r-- | tests/metatype/ttensor.nim | 41 |
2 files changed, 42 insertions, 1 deletions
diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim index 78d245a97..fd703a433 100644 --- a/compiler/sighashes.nim +++ b/compiler/sighashes.nim @@ -224,7 +224,7 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) = c &= ',' else: for i in countup(0, sonsLen(t) - 1): c.hashType t.sons[i], flags - of tyRange: + of tyRange, tyStatic: #if CoType notin flags: c.hashTree(t.n) c.hashType(t.sons[0], flags) diff --git a/tests/metatype/ttensor.nim b/tests/metatype/ttensor.nim new file mode 100644 index 000000000..f2f24ba8c --- /dev/null +++ b/tests/metatype/ttensor.nim @@ -0,0 +1,41 @@ +discard """ + output: '''before tensor2: +[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0] + +before tensor3: +[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0] + +after tensor3: +[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0] + +a3: +[1000.0, 1001.0, 1002.0, 1003.0, 1004.0, 1005.0, 1006.0, 1007.0, 1008.0, 1009.0, 1010.0, 1011.0, 1012.0, 1013.0, 1014.0, 1015.0, 1016.0, 1017.0, 1018.0, 1019.0, 1020.0, 1021.0, 1022.0, 1023.0, 1024.0, 1025.0, 1026.0]''' +""" + +import macros + +type + Tensor[Dim : static[int]] = object + data: array[Dim, float64] + +proc transpose(tensor: Tensor): Tensor = + # fake implementation, don't transpose anything at all + # just do something to see a change happening + for i in 0 ..< tensor.data.len: + result.data[i] = 1000 + tensor.data[i] + +var tensor2: Tensor[24] +var tensor3: Tensor[27] + +for i, x in tensor2.data.mpairs(): + x = float64(i) + +for i, x in tensor3.data.mpairs(): + x = float64(i) + +echo "before tensor2:\n", tensor2.data.repr +echo "before tensor3:\n", tensor3.data.repr + +var a3 = transpose(tensor3) +echo "after tensor3:\n", tensor3.data.repr +echo "a3:\n", a3.data.repr |