{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/7593","repository_url":"https://api.github.com/repos/nim-lang/Nim","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/7593/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/7593/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/7593/events","html_url":"https://github.com/nim-lang/Nim/issues/7593","id":313973972,"node_id":"MDU6SXNzdWUzMTM5NzM5NzI=","number":7593,"title":"async proc or closure iterator with specific variable names causes invalid C code generation","user":{"login":"tersec","id":11422416,"node_id":"MDQ6VXNlcjExNDIyNDE2","avatar_url":"https://avatars0.githubusercontent.com/u/11422416?v=4","gravatar_id":"","url":"https://api.github.com/users/tersec","html_url":"https://github.com/tersec","followers_url":"https://api.github.com/users/tersec/followers","following_url":"https://api.github.com/users/tersec/following{/other_user}","gists_url":"https://api.github.com/users/tersec/gists{/gist_id}","starred_url":"https://api.github.com/users/tersec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tersec/subscriptions","organizations_url":"https://api.github.com/users/tersec/orgs","repos_url":"https://api.github.com/users/tersec/repos","events_url":"https://api.github.com/users/tersec/events{/privacy}","received_events_url":"https://api.github.com/users/tersec/received_events","type":"User","site_admin":false},"labels":[{"id":352133737,"node_id":"MDU6TGFiZWwzNTIxMzM3Mzc=","url":"https://api.github.com/repos/nim-lang/Nim/labels/Async","name":"Async","color":"d93f0b","default":false},{"id":601375915,"node_id":"MDU6TGFiZWw2MDEzNzU5MTU=","url":"https://api.github.com/repos/nim-lang/Nim/labels/Iterators","name":"Iterators","color":"b7de92","default":false},{"id":431542100,"node_id":"MDU6TGFiZWw0MzE1NDIxMDA=","url":"https://api.github.com/repos/nim-lang/Nim/labels/Templates","name":"Templates","color":"c9d615","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-13T05:30:13Z","updated_at":"2018-06-07T12:10:36Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"A sufficient (on 0.17.2 and current git head) few lines of code:\r\n```\r\nimport asyncdispatch, sequtils, tables\r\n\r\n# These table types don't seem to much matter, but I've\r\n# not reproduced it without a TableRef.\r\nproc main(): Future[void] {.async.} =\r\n  let h1 = newTable(@[(\"\", \"\")])\r\n  let v2 = toSeq(values(h1))\r\n  let v3 = toSeq(keys(h1))\r\n```\r\nChange the variable name h1 to anything else I've tried, and it compiles, but with h1:\r\n```\r\nError: execution of an external compiler program 'gcc -c  -w  -I/home/user/Nim/lib -o /home/user/nimcache/test0.o /home/user/nimcache/test0.c' failed with exit code: 1\r\n\r\n/home/user/nimcache/test0.c:207:4: error: duplicate member ‘h11’\r\n NI h11;\r\n    ^~~\r\n/home/user/nimcache/test0.c: In function ‘mainIter_5hUhZnHE8acBHekkyBVVlQ’:\r\n/home/user/nimcache/test0.c:701:87: error: array subscript is not an integer\r\n       T20_ = isFilled_IxXD1UAPoEehVDW9cv9cRaew_2tables((*(*colonenvP_).h11).data->data[(*colonenvP_).h11].Field0);\r\n                                                                                       ^\r\n/home/user/nimcache/test0.c:704:84: error: array subscript is not an integer\r\n       asgnRefNoCycle((void**) (&(*colonenvP_).x10), (*(*colonenvP_).h11).data->data[(*colonenvP_).h11].Field1);\r\n```\r\n\r\nUsing nimDumpAsync and removing unnecessary-for-reproduction parts:\r\n```\r\nimport asyncdispatch, sequtils, tables\r\n\r\nproc main(): Future[void] =\r\n  var retFuture254020 = newFuture[void](\"main\")\r\n  iterator mainIter254021(): FutureBase {.closure.} =\r\n    let h1 = newTable(@[(\"\", \"\")])\r\n    let v2 = toSeq(keys(h1))\r\n    let v3 = toSeq(keys(h1))\r\n    complete(retFuture254020)\r\n\r\n  var nameIterVar254024 = mainIter254021\r\n  return retFuture254020\r\n```\r\nThe types for which the TableRef is instantiated don't seem to much matter."},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/395397863","html_url":"https://github.com/nim-lang/Nim/issues/7593#issuecomment-395397863","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/7593","id":395397863,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTM5Nzg2Mw==","user":{"login":"data-man","id":1754269,"node_id":"MDQ6VXNlcjE3NTQyNjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1754269?v=4","gravatar_id":"","url":"https://api.github.com/users/data-man","html_url":"https://github.com/data-man","followers_url":"https://api.github.com/users/data-man/followers","following_url":"https://api.github.com/users/data-man/following{/other_user}","gists_url":"https://api.github.com/users/data-man/gists{/gist_id}","starred_url":"https://api.github.com/users/data-man/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/data-man/subscriptions","organizations_url":"https://api.github.com/users/data-man/orgs","repos_url":"https://api.github.com/users/data-man/repos","events_url":"https://api.github.com/users/data-man/events{/privacy}","received_events_url":"https://api.github.com/users/data-man/received_events","type":"User","site_admin":false},"created_at":"2018-06-07T12:10:36Z","updated_at":"2018-06-07T12:10:36Z","author_association":"COLLABORATOR","body":"Works on Arch Linux, it's not surprising. :)"}}
{"actor":{"display_login":"data-man"}}