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

bits not exported, leading to failure with generic proc #72

Open
andreaferretti opened this issue Dec 17, 2018 · 2 comments
Open

bits not exported, leading to failure with generic proc #72

andreaferretti opened this issue Dec 17, 2018 · 2 comments

Comments

@andreaferretti
Copy link

If I try to define the simple proc

import stint

proc id[N: static int](x: typedesc[StInt[N]]): StInt[N] = 1.stint(N)

let x = id(StInt[8])

I get the error

example.nim(5, 11) template/generic instantiation of `id` from here
../../.nimble/pkgs/stint-0.0.1/stint/private/datatypes.nim(167, 20) Error: undeclared identifier: 'bits'

(I am trying to make stint interop with emmy)

@mratsim
Copy link
Contributor

mratsim commented Jan 8, 2019

That's strange, bits is a static int not a type. It's equivalent to N in array[N, T]

@jangko
Copy link
Contributor

jangko commented May 11, 2019

workaround:

import stint

proc id[N: static int](T: typedesc[StInt[N]]): T = 1.stint(N)

let x = id(StInt[8])

perhaps Nim compiler nerve system not wired properly around generic static param, but the typedesc nerve does.

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