Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: type mismatch on echo #348

Closed
sdickreuter opened this issue Feb 7, 2019 · 3 comments
Closed

Error: type mismatch on echo #348

sdickreuter opened this issue Feb 7, 2019 · 3 comments

Comments

@sdickreuter
Copy link

Hi !

I'm a newbie with nim and I was trying out some arraymancer examples to get a feel on the usage, but when I run the example code

import arraymancer

let d = [[1, 2, 3], [4, 5, 6]].toTensor()

echo d
# Tensor of shape 2x3 of type "int" on backend "Cpu"
# |1      2       3|
# |4      5       6|

echo d.rank # 2
echo d.shape # @[2, 3]
echo d.strides # @[3, 1] => Next row is 3 elements away in memory while next column is 1 element away.
echo d.offset # 0

compilation fails:

bla.nim(5, 6) template/generic instantiation of $ from here
../../.nimble/pkgs/arraymancer-#head/tensor/display.nim(25, 27) template/generic instantiation of disp3d from here
../../.nimble/pkgs/arraymancer-#head/tensor/private/p_display.nim(96, 17) Error: type mismatch: got <Tensor[system.int], proc (x: GenericParam): untyped>
but expected one of:
proc map[T, S](s: openArray[T]; op: proc (x: T): S {.closure.}): seq[S]
first type mismatch at position: 1
required type: openarray[T]
but expression 't0' is of type: Tensor[system.int]

expression: map(t0, proc (x: auto): auto = $x)
[Finished in 1.2s with exit code 1]

if I remove echo d it compiles and runs fine.
I'm running latest nim from git (1:0.19.4.r1306.c7c495f08-1) and have the issue on arraymancer 5.0 and head.
Any help is appreciated!
cheers
Simon

@chimez
Copy link
Contributor

chimez commented Feb 10, 2019

Adding type hinting of map will fix it.

@mratsim
Copy link
Owner

mratsim commented Feb 10, 2019

AFAIK this was a regression in Nim, that was detected by @Araq when he added popular packages to Nim regression test in nim-lang/Nim@f4c76bc and nim-lang/Nim@6e1d2df.

I tried on latest devel but it's still failing so maybe the fix is in a branch. It works on stable though.

Thanks @chimez for the PR I'll merge it.

@sdickreuter
Copy link
Author

Thank y'all for the quick reaction and fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants