{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/8521","repository_url":"https://api.github.com/repos/nim-lang/Nim","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/8521/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/8521/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/8521/events","html_url":"https://github.com/nim-lang/Nim/issues/8521","id":347269363,"node_id":"MDU6SXNzdWUzNDcyNjkzNjM=","number":8521,"title":"[BLOCKER] `Error: invalid type for const: T` prevents default initializing at compile time when T has a reference field","user":{"login":"timotheecour","id":2194784,"node_id":"MDQ6VXNlcjIxOTQ3ODQ=","avatar_url":"https://avatars2.githubusercontent.com/u/2194784?v=4","gravatar_id":"","url":"https://api.github.com/users/timotheecour","html_url":"https://github.com/timotheecour","followers_url":"https://api.github.com/users/timotheecour/followers","following_url":"https://api.github.com/users/timotheecour/following{/other_user}","gists_url":"https://api.github.com/users/timotheecour/gists{/gist_id}","starred_url":"https://api.github.com/users/timotheecour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timotheecour/subscriptions","organizations_url":"https://api.github.com/users/timotheecour/orgs","repos_url":"https://api.github.com/users/timotheecour/repos","events_url":"https://api.github.com/users/timotheecour/events{/privacy}","received_events_url":"https://api.github.com/users/timotheecour/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-03T05:59:52Z","updated_at":"2018-08-03T07:30:37Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"```nim\r\nproc defaultImpl[T]():T=\r\n  var a: T\r\n  return a\r\n\r\ntype App = object\r\n  a: ref int\r\n\r\nproc foo(): auto=\r\n  let val = defaultImpl[App]()\r\n  return val\r\n\r\nproc test(): auto=\r\n  when defined(case1):\r\n    # ok\r\n    const val = defaultImpl[ref int]()\r\n    echo repr(val)\r\n\r\n  when defined(case2):\r\n    # Error: invalid type for const: App\r\n    const val = defaultImpl[App]()\r\n\r\n  when defined(case3):\r\n    # ok\r\n    let val = defaultImpl[App]()\r\n    echo repr(val)\r\n\r\n  when defined(case4):\r\n    # Error: invalid type for const: App\r\n    const val = foo()\r\n\r\ntest()\r\n```\r\n\r\n/cc @Araq \r\nThis is a blocker for doing compile time reflection (and doing many things that rely on it). Any chance this could be fixed?\r\n\r\n* it also limits https://github.com/nim-lang/Nim/pull/8490\r\n"},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/410170145","html_url":"https://github.com/nim-lang/Nim/issues/8521#issuecomment-410170145","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/8521","id":410170145,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDE3MDE0NQ==","user":{"login":"andreaferretti","id":1962818,"node_id":"MDQ6VXNlcjE5NjI4MTg=","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":"2018-08-03T07:30:37Z","updated_at":"2018-08-03T07:30:37Z","author_association":"COLLABORATOR","body":"I think this makes sense, right? You cannot have a constant reference, the actual address will be unknown until runtime. You *can* do this in the case of nil, although I am not sure how useful this is"}}
{"actor":{"display_login":"andreaferretti"}}