{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/8144","repository_url":"https://api.github.com/repos/nim-lang/Nim","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/8144/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/8144/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/8144/events","html_url":"https://github.com/nim-lang/Nim/issues/8144","id":336642888,"node_id":"MDU6SXNzdWUzMzY2NDI4ODg=","number":8144,"title":"non-intuitive json '%*' macro behaviour","user":{"login":"zevv","id":3001919,"node_id":"MDQ6VXNlcjMwMDE5MTk=","avatar_url":"https://avatars3.githubusercontent.com/u/3001919?v=4","gravatar_id":"","url":"https://api.github.com/users/zevv","html_url":"https://github.com/zevv","followers_url":"https://api.github.com/users/zevv/followers","following_url":"https://api.github.com/users/zevv/following{/other_user}","gists_url":"https://api.github.com/users/zevv/gists{/gist_id}","starred_url":"https://api.github.com/users/zevv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zevv/subscriptions","organizations_url":"https://api.github.com/users/zevv/orgs","repos_url":"https://api.github.com/users/zevv/repos","events_url":"https://api.github.com/users/zevv/events{/privacy}","received_events_url":"https://api.github.com/users/zevv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-28T14:21:33Z","updated_at":"2018-06-28T14:57:18Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"\r\nI understand the two cases below result in a different way the `%*` macro is handled, but from a user view the result feels a bit odd: the first example works as expected, but the second fails at compile time.\r\n\r\n```\r\nimport json\r\n\r\n\r\n# This works\r\n\r\nlet a = %* { \"cat\": 23, \"dog\": [ 1, 2, 3 ] }\r\necho a.pretty\r\n\r\n# This does not\r\n\r\nlet a = { \"cat\": 23, \"dog\": [ 1, 2, 3 ] }\r\nlet b = %* a\r\n```\r\n\r\nResulting in\r\n\r\n```\r\nt.nim(11, 27) Error: type mismatch: got <tuple of (string, array[0..2, int])> but expected 'tuple of (string, int)'\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/401064179","html_url":"https://github.com/nim-lang/Nim/issues/8144#issuecomment-401064179","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/8144","id":401064179,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTA2NDE3OQ==","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-06-28T14:57:18Z","updated_at":"2018-06-28T14:57:18Z","author_association":"COLLABORATOR","body":"More generally, the point of macros is - often - to allow to do things that functions cannot do by working on the AST, so I don't think it is a reasonable expectation that they should work on a variable, because then they cannot see the AST at all.\r\n\r\nFor another example (using jester), the following works:\r\n\r\n```nim\r\nimport jester, asyncdispatch, htmlgen\r\n\r\nroutes:\r\n  get \"/\":\r\n    resp h1(\"Hello world\")\r\n\r\nrunForever()\r\n```\r\n\r\nbut this doesn't\r\n\r\n```nim\r\nimport jester, asyncdispatch, htmlgen\r\n\r\nlet x = get \"/\":\r\n  resp h1(\"Hello world\")\r\nroutes(x)\r\n\r\nrunForever()\r\n```"}}
{"actor":{"display_login":"andreaferretti"}}