Inside a macro, the length of the `seq` data inside a `queue` does not increase and crashes #4422

jxy opened this Issue Jun 27, 2016 · 0 comments


None yet

2 participants

jxy commented Jun 27, 2016

Using nim v0.14.2

import queues,macros
macro t(n: untyped): untyped =
  var q = initQueue[NimNode]()
  q.add n
  while q.len > 0:
    for c in q.dequeue:
      if c.kind == nnkIdent: echo c
      elif c.kind notin AtomicNodes: q.add c
  result = newstmtlist()
  x = y
  x = y
  x = y
  x = y
  x = y

Crashes with

stack trace: (most recent call last)
lib/core/macros.nim(746) t
t_queue.nim(10, 1) template/generic instantiation from here
lib/core/macros.nim(746, 12) Error: index out of bounds
@Araq Araq added VM Crash labels Jul 8, 2016
@Araq Araq closed this in #4472 Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment