{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/6269","repository_url":"https://api.github.com/repos/nim-lang/Nim","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/6269/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/6269/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/6269/events","html_url":"https://github.com/nim-lang/Nim/issues/6269","id":252338319,"number":6269,"title":"Nested calls to same iterator fail with \"var not init\"","user":{"login":"nazgul17","id":1052500,"avatar_url":"https://avatars2.githubusercontent.com/u/1052500?v=4","gravatar_id":"","url":"https://api.github.com/users/nazgul17","html_url":"https://github.com/nazgul17","followers_url":"https://api.github.com/users/nazgul17/followers","following_url":"https://api.github.com/users/nazgul17/following{/other_user}","gists_url":"https://api.github.com/users/nazgul17/gists{/gist_id}","starred_url":"https://api.github.com/users/nazgul17/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nazgul17/subscriptions","organizations_url":"https://api.github.com/users/nazgul17/orgs","repos_url":"https://api.github.com/users/nazgul17/repos","events_url":"https://api.github.com/users/nazgul17/events{/privacy}","received_events_url":"https://api.github.com/users/nazgul17/received_events","type":"User","site_admin":false},"labels":[{"id":385324188,"url":"https://api.github.com/repos/nim-lang/Nim/labels/Crash","name":"Crash","color":"b60205","default":false},{"id":202793755,"url":"https://api.github.com/repos/nim-lang/Nim/labels/Error%20messages","name":"Error messages","color":"ded47c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-23T16:12:44Z","updated_at":"2017-08-28T07:57:18Z","closed_at":null,"body":"I tried to run the following code\r\n```\r\nimport future\r\n\r\niterator combinations*(pool: seq[char], r: int): seq[char] =\r\n  # combinations(@['A','B','C','D'], 2) --> AB AC AD BC BD CD\r\n  block it:\r\n    let n = pool.len\r\n    if r > n:\r\n      break it\r\n    var indices = lc[i | (i <- 0..<r), int]\r\n    yield lc[pool[i] | (i <- indices), char]\r\n    while true:\r\n      var i = r - 1\r\n      block forElse:\r\n        while i >= 0:\r\n          if indices[i] != i + n - r:\r\n            break forElse\r\n          i -= 1\r\n        break it\r\n      indices[i] += 1\r\n      for j in i+1..<r:\r\n        indices[j] = indices[j-1] + 1\r\n      yield lc[pool[i] | (i <- indices), char]\r\n\r\nfor s1 in combinations(@['A','B','C','D'], 2):\r\n  echo s1\r\n  for s2 in combinations(@['1','2','3','4'], 2):\r\n    echo s1, \" \", s2\r\n  \r\n```\r\nbut it fails with\r\n```\r\nexample.nim(3, 10) Error: internal error: expr: var not init :env_110863\r\nNo stack traceback available\r\nTo create a stacktrace, rerun compilation with ./koch temp c <file>\r\n```\r\nHowever, only one loop runs with no problems:\r\n```\r\nfor s1 in combinations(@['A','B','C','D'], 2):\r\n  echo s1\r\n```\r\nprinting\r\n```\r\n@[A, B]\r\n@[A, C]\r\n@[A, D]\r\n@[B, C]\r\n@[B, D]\r\n@[C, D]\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/325286478","html_url":"https://github.com/nim-lang/Nim/issues/6269#issuecomment-325286478","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/6269","id":325286478,"user":{"login":"andreaferretti","id":1962818,"avatar_url":"https://avatars1.githubusercontent.com/u/1962818?v=4","gravatar_id":"","url":"https://api.github.com/users/andreaferretti","html_url":"https://github.com/andreaferretti","followers_url":"https://api.github.com/users/andreaferretti/followers","following_url":"https://api.github.com/users/andreaferretti/following{/other_user}","gists_url":"https://api.github.com/users/andreaferretti/gists{/gist_id}","starred_url":"https://api.github.com/users/andreaferretti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreaferretti/subscriptions","organizations_url":"https://api.github.com/users/andreaferretti/orgs","repos_url":"https://api.github.com/users/andreaferretti/repos","events_url":"https://api.github.com/users/andreaferretti/events{/privacy}","received_events_url":"https://api.github.com/users/andreaferretti/received_events","type":"User","site_admin":false},"created_at":"2017-08-28T07:57:18Z","updated_at":"2017-08-28T07:57:18Z","body":"Why not? It seems a reasonable use of iterators"}}
{"actor":{"display_login":"andreaferretti"}}