{"action":"created","issue":{"url":"https://api.github.com/repos/ponylang/ponyc/issues/607","repository_url":"https://api.github.com/repos/ponylang/ponyc","labels_url":"https://api.github.com/repos/ponylang/ponyc/issues/607/labels{/name}","comments_url":"https://api.github.com/repos/ponylang/ponyc/issues/607/comments","events_url":"https://api.github.com/repos/ponylang/ponyc/issues/607/events","html_url":"https://github.com/ponylang/ponyc/issues/607","id":141929379,"number":607,"title":"Assertion failure in \"Generating\" phase","user":{"login":"andrenth","id":30213,"avatar_url":"https://avatars.githubusercontent.com/u/30213?v=3","gravatar_id":"","url":"https://api.github.com/users/andrenth","html_url":"https://github.com/andrenth","followers_url":"https://api.github.com/users/andrenth/followers","following_url":"https://api.github.com/users/andrenth/following{/other_user}","gists_url":"https://api.github.com/users/andrenth/gists{/gist_id}","starred_url":"https://api.github.com/users/andrenth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrenth/subscriptions","organizations_url":"https://api.github.com/users/andrenth/orgs","repos_url":"https://api.github.com/users/andrenth/repos","events_url":"https://api.github.com/users/andrenth/events{/privacy}","received_events_url":"https://api.github.com/users/andrenth/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ponylang/ponyc/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/ponylang/ponyc/labels/easy","name":"easy","color":"009800"}],"state":"closed","locked":false,"assignee":{"login":"sylvanc","id":2785007,"avatar_url":"https://avatars.githubusercontent.com/u/2785007?v=3","gravatar_id":"","url":"https://api.github.com/users/sylvanc","html_url":"https://github.com/sylvanc","followers_url":"https://api.github.com/users/sylvanc/followers","following_url":"https://api.github.com/users/sylvanc/following{/other_user}","gists_url":"https://api.github.com/users/sylvanc/gists{/gist_id}","starred_url":"https://api.github.com/users/sylvanc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sylvanc/subscriptions","organizations_url":"https://api.github.com/users/sylvanc/orgs","repos_url":"https://api.github.com/users/sylvanc/repos","events_url":"https://api.github.com/users/sylvanc/events{/privacy}","received_events_url":"https://api.github.com/users/sylvanc/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-03-18T17:22:30Z","updated_at":"2016-03-18T19:23:38Z","closed_at":"2016-03-18T19:23:38Z","body":"The following code triggers an assertion error in ponyc:\r\n\r\n```pony\r\ntype S is (I8 | I16)\r\ntype U is (U8 | U16)\r\ntype T is (S | U | None)\r\n\r\nactor Main\r\n  new create(env: Env) =>\r\n    let a = Array[T](1)\r\n    let x: I8 = 1\r\n    a.push(x)\r\n    for (i, t) in a.pairs() do\r\n      match t\r\n      | let s: (S | U) => env.out.print(s.string())\r\n      end\r\n    end\r\n```\r\n\r\n```\r\n$ ponyc\r\nBuilding builtin -> /usr/local/lib/pony/0.2.1-630-gf2030d0/packages/builtin\r\nBuilding . -> /home/andre/pony/hello\r\nGenerating\r\nponyc: src/libponyc/codegen/gencall.c:186: dispatch_function: Assertion `index != (uint32_t)-1' failed.\r\nzsh: abort (core dumped)  ponyc\r\n```\r\n\r\nI've noticed that changing either types `S` or `U` to be an alias to a primitive type (i.e. `type S = I8` or `type U = U8`) then the assertion will not fail. It also won't fail if in the `match` expression I write one branch for `S` and one for `U`, instead of matching on the union."},"comment":{"url":"https://api.github.com/repos/ponylang/ponyc/issues/comments/198507624","html_url":"https://github.com/ponylang/ponyc/issues/607#issuecomment-198507624","issue_url":"https://api.github.com/repos/ponylang/ponyc/issues/607","id":198507624,"user":{"login":"sylvanc","id":2785007,"avatar_url":"https://avatars.githubusercontent.com/u/2785007?v=3","gravatar_id":"","url":"https://api.github.com/users/sylvanc","html_url":"https://github.com/sylvanc","followers_url":"https://api.github.com/users/sylvanc/followers","following_url":"https://api.github.com/users/sylvanc/following{/other_user}","gists_url":"https://api.github.com/users/sylvanc/gists{/gist_id}","starred_url":"https://api.github.com/users/sylvanc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sylvanc/subscriptions","organizations_url":"https://api.github.com/users/sylvanc/orgs","repos_url":"https://api.github.com/users/sylvanc/repos","events_url":"https://api.github.com/users/sylvanc/events{/privacy}","received_events_url":"https://api.github.com/users/sylvanc/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T19:23:38Z","updated_at":"2016-03-18T19:23:38Z","body":"Nice catch! Fixed."}}