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

metagn added a commit to metagn/Nim that referenced this issue Dec 8, 2024
@Araq Araq closed this as completed in aeb3fe9 Dec 9, 2024
narimiran pushed a commit that referenced this issue Jan 14, 2025
closes #6013, closes #7009, closes #9190, closes #12487, closes #12831,
closes #13184, closes #13252, closes #14860, closes #14877, closes
#14894, closes #14917, closes #16153, closes #16439, closes #17779,
closes #18074, closes #18202, closes #18314, closes #18648, closes
#19063, closes #19446, closes #20065, closes #20367, closes #22126,
closes #22820, closes #22888, closes #23020, closes #23287, closes
#23510

(cherry picked from commit aeb3fe9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants