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

Importing std/enumerate breaks arraymancer #536

Open
dain-xyz opened this issue Dec 3, 2021 · 1 comment
Open

Importing std/enumerate breaks arraymancer #536

dain-xyz opened this issue Dec 3, 2021 · 1 comment

Comments

@dain-xyz
Copy link

dain-xyz commented Dec 3, 2021

This works:

import arraymancer
let foo = @[1, 2, 3].to_tensor
echo foo

This doesn't:

import arraymancer
import std/enumerate

let foo = @[1, 2, 3].to_tensor
echo foo
Error: type mismatch: got <Tensor[system.int]>
but expected one of:
proc echo(x: varargs[typed, `$`])
  first type mismatch at position: 1
  required type for x: varargs[typed]
  but expression 'foo' is of type: Tensor[system.int]

expression: echo foo

Version info:

nim --version
Nim Compiler Version 1.6.0 [Linux: amd64]
Compiled at 2021-10-19
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 727c6378d2464090564dbcd9bc8b9ac648467e38
active boot switches: -d:release
@Vindaar
Copy link
Collaborator

Vindaar commented Dec 3, 2021

Interesting. Thanks for the report.

I stumbled on possibly the same issue before, but always in complex situations and could never find a simple example. I'll see whether I can fix it somehow.

edit:

The following is already enough to trigger the issue:

import arraymancer
import macros

macro enumerate*(x: ForLoopStmt): untyped =
  result.add newLit(0)

let foo = @[1, 2, 3].toTensor
echo foo

Note: The ForLoopStmt is required. If using typed or untyped it works. It also works if the argument of enumerate is not an add stmt (i.e. just discard or result = newStmtList(). Maybe something else triggers it too though).

Also changing the name of the macro to something other than enumerate makes the code compile. The issue is likely that the ForLoopStmt macros mess up the overload resolution within arraymancer, as there are enumerate iterators.

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

2 participants