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

Static - multi-parameters: Nim expects all generics to be instantiated by first variable #5641

Closed
mratsim opened this issue Apr 1, 2017 · 1 comment
Assignees

Comments

@mratsim
Copy link
Collaborator

mratsim commented Apr 1, 2017

When a proc accept 2 generic parameters, Nim expects the generics to be instantiated after the first variable.

Test case:

type
  Matrix[M,N: static[int]; T: SomeReal] = array[0..(M*N - 1), T]

let a = new Matrix[2,2,float]
let b = new Matrix[2,1,float]

proc foo[M,N: static[int],T](a: ref Matrix[M, N, T], b: ref Matrix[M, N, T])=
    discard

foo(a, a) #works
foo(a, b) #works

proc bar[M,N: static[int],T](a: ref Matrix[M, M, T], b: ref Matrix[M, N, T])=
    discard

bar(a, b) #cannot instantiate: 'N'
bar(a, a) #cannot instantiate: 'N'

proc baz[M,N: static[int],T](a: ref Matrix[N, N, T], b: ref Matrix[M, N, T])=
    discard

baz(a, b) #cannot instantiate: 'M'
baz(a, a) #cannot instantiate: 'M'

CC-ing @andreaferretti

@mratsim mratsim changed the title Static - multi-parameters: Nim expect all generics to be instantiated by first variable Static - multi-parameters: Nim expects all generics to be instantiated by first variable Apr 1, 2017
@zah zah self-assigned this Apr 1, 2017
@andreaferretti
Copy link
Collaborator

This seems to be related

@Araq Araq closed this as completed in e9a3ffb May 17, 2017
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