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 seqs are turned into static arrays when passed through template. #14917

Closed
solo989 opened this issue Jul 6, 2020 · 2 comments · Fixed by #24525
Closed

Static seqs are turned into static arrays when passed through template. #14917

solo989 opened this issue Jul 6, 2020 · 2 comments · Fixed by #24525

Comments

@solo989
Copy link
Contributor

solo989 commented Jul 6, 2020

Example

proc passSeq2[T](a : static seq[T]) =
  echo a

template passSeq1[T](a : static seq[T]) =
  static:
    echo type(a)
  passSeq2(a)

passSeq1(@[5,6])

Current Output

array[0..1, int]
testNim.nim(11, 9) Error: type mismatch:
got <static[array[0..1, int]]([5, 6])>
but expected one of:
proc passSeq2[T](a: static seq[T])
  first type mismatch at position: 1
  required type for a: static[seq[T]]
  but expression '[5, 6]' is of type: static[array[0..1, int]]([5, 6])

expression: passSeq2([5, 6])

Expected Output

seq[int]
@[5,6]
$ nim -v
Nim Compiler Version 1.2.2 [Windows: amd64]
@timotheecour
Copy link
Member

timotheecour commented Jul 6, 2020

workaround: either of those would work:
template passSeq1(a) =
template passSeq1(a: typed) =
template passSeq1T =

@metagn
Copy link
Collaborator

metagn commented Nov 3, 2024

Works in devel probably since #24224

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