You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But if I move the proc to its own module, named foo, and try to import it like this...
import foo
echodedupe([1, 2, 3])
I get this error:
nim_misc.nim(3, 12) template/generic instantiation of `dedupe` from here
nim_misc/src/foo.nim(4, 6) Error: type mismatch: got <HashSet[system.int]>
but expected one of:
iterator items(E: typedesc[enum]): E:type
first type mismatch at position: 1
required type for E: type enum
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items(a: cstring): char
first type mismatch at position: 1
required type for a: cstring
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items(a: string): char
first type mismatch at position: 1
required type for a: string
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items[IX, T](a: array[IX, T]): T
first type mismatch at position: 1
required type for a: array[IX, T]
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items[T: char](a: openArray[T]): T
first type mismatch at position: 1
required type for a: openArray[T: char]
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items[T: not char](a: openArray[T]): lent2 T
first type mismatch at position: 1
required type for a: openArray[T: not char]
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items[T](a: seq[T]): lent2 T
first type mismatch at position: 1
required type for a: seq[T]
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items[T](a: set[T]): T
first type mismatch at position: 1
required type for a: set[T]
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
iterator items[T](s: HSlice[T, T]): T
first type mismatch at position: 1
required type for s: HSlice[items.T, items.T]
but expression 'toHashSet(arr)' is of type: HashSet[system.int]
Expected Output
The import should work without error.
Possible Solution
If you put import sets before the import foo, it works.
In the foo module, if you do export sets.items it works.
If you make dedupe a non-generic function (declaring it as proc dedupe*(arr: openArray[int]): seq[int] for example) it works.
Additional Information
$ nim -v
Nim Compiler Version 1.4.2 [MacOSX: amd64]
Compiled at 2020-12-21
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
The text was updated successfully, but these errors were encountered:
The following code works:
But if I move the proc to its own module, named
foo
, and try to import it like this...I get this error:
Expected Output
The
import
should work without error.Possible Solution
import sets
before theimport foo
, it works.foo
module, if you doexport sets.items
it works.dedupe
a non-generic function (declaring it asproc dedupe*(arr: openArray[int]): seq[int]
for example) it works.Additional Information
The text was updated successfully, but these errors were encountered: