{"action":"created","issue":{"url":"https://api.github.com/repos/ponylang/ponyc/issues/2003","repository_url":"https://api.github.com/repos/ponylang/ponyc","labels_url":"https://api.github.com/repos/ponylang/ponyc/issues/2003/labels{/name}","comments_url":"https://api.github.com/repos/ponylang/ponyc/issues/2003/comments","events_url":"https://api.github.com/repos/ponylang/ponyc/issues/2003/events","html_url":"https://github.com/ponylang/ponyc/issues/2003","id":240028691,"number":2003,"title":"Error when consuming `iso` returned from a function to use as parameter for another function","user":{"login":"dipinhora","id":11946442,"avatar_url":"https://avatars0.githubusercontent.com/u/11946442?v=3","gravatar_id":"","url":"https://api.github.com/users/dipinhora","html_url":"https://github.com/dipinhora","followers_url":"https://api.github.com/users/dipinhora/followers","following_url":"https://api.github.com/users/dipinhora/following{/other_user}","gists_url":"https://api.github.com/users/dipinhora/gists{/gist_id}","starred_url":"https://api.github.com/users/dipinhora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dipinhora/subscriptions","organizations_url":"https://api.github.com/users/dipinhora/orgs","repos_url":"https://api.github.com/users/dipinhora/repos","events_url":"https://api.github.com/users/dipinhora/events{/privacy}","received_events_url":"https://api.github.com/users/dipinhora/received_events","type":"User","site_admin":false},"labels":[{"id":283122357,"url":"https://api.github.com/repos/ponylang/ponyc/labels/difficulty:%201%20-%20easy","name":"difficulty: 1 - easy","color":"009800","default":false},{"id":353620204,"url":"https://api.github.com/repos/ponylang/ponyc/labels/enhancement:%204%20-%20in%20progress","name":"enhancement: 4 - in progress","color":"fbca04","default":false},{"id":353596859,"url":"https://api.github.com/repos/ponylang/ponyc/labels/priority:%201%20-%20low","name":"priority: 1 - low","color":"e99695","default":false},{"id":572440088,"url":"https://api.github.com/repos/ponylang/ponyc/labels/project%20error%20message","name":"project error message","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":{"login":"jemc","id":4623870,"avatar_url":"https://avatars3.githubusercontent.com/u/4623870?v=3","gravatar_id":"","url":"https://api.github.com/users/jemc","html_url":"https://github.com/jemc","followers_url":"https://api.github.com/users/jemc/followers","following_url":"https://api.github.com/users/jemc/following{/other_user}","gists_url":"https://api.github.com/users/jemc/gists{/gist_id}","starred_url":"https://api.github.com/users/jemc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jemc/subscriptions","organizations_url":"https://api.github.com/users/jemc/orgs","repos_url":"https://api.github.com/users/jemc/repos","events_url":"https://api.github.com/users/jemc/events{/privacy}","received_events_url":"https://api.github.com/users/jemc/received_events","type":"User","site_admin":false},"assignees":[{"login":"jemc","id":4623870,"avatar_url":"https://avatars3.githubusercontent.com/u/4623870?v=3","gravatar_id":"","url":"https://api.github.com/users/jemc","html_url":"https://github.com/jemc","followers_url":"https://api.github.com/users/jemc/followers","following_url":"https://api.github.com/users/jemc/following{/other_user}","gists_url":"https://api.github.com/users/jemc/gists{/gist_id}","starred_url":"https://api.github.com/users/jemc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jemc/subscriptions","organizations_url":"https://api.github.com/users/jemc/orgs","repos_url":"https://api.github.com/users/jemc/repos","events_url":"https://api.github.com/users/jemc/events{/privacy}","received_events_url":"https://api.github.com/users/jemc/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2017-07-02T19:10:40Z","updated_at":"2017-07-03T01:45:40Z","closed_at":null,"body":"**Use case:** I have function `A` which does some work and returns an `Array[U8] iso`. I then want to take that and consume it as an argument for function `B` which is also expecting an `Array[U8] iso`. This results in a compiler error.\r\n\r\n**Code:**\r\n\r\nPlaypen link: http://pony-playpen.lietar.net/?gist=fa2f2f5f8647cd146aa32c3605dc6ad0\r\n\r\n```Pony\r\nactor Main\r\n  new create(env:Env) =>\r\n    let d = f()\r\n\r\n    let d' = g(consume iso d)\r\n\r\n  fun f(): Array[U8] iso =>\r\n    let d = recover Array[U8] end\r\n    d.push(4)\r\n    d.push(4)\r\n    d.push(4)\r\n    d.push(4)\r\n    d\r\n\r\n  fun g(data: Array[U8] iso) =>\r\n    None\r\n```\r\n\r\n**Error:**\r\n\r\n```\r\n0.14.0 [release]\r\ncompiled with: llvm 3.9.1 -- cc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609\r\nError:\r\nmain.pony:5:16: argument not a subtype of parameter\r\n    let d' = g(consume iso d)\r\n               ^\r\n    Info:\r\n    main.pony:7:12: Array[U8 val] iso! is not a subtype of Array[U8 val] iso: iso! is not a subcap of iso\r\n      fun f(): Array[U8] iso =>\r\n               ^\r\n```\r\n\r\n**Additional info:**\r\n\r\nChanging the `iso` in `g(consume iso d)` and `g(data: Array[U8] iso)` to `trn` results in a similar error:\r\n\r\n```\r\n0.14.0 [release]\r\ncompiled with: llvm 3.9.1 -- cc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609\r\nError:\r\nmain.pony:5:16: argument not a subtype of parameter\r\n    let d' = g(consume trn d)\r\n               ^\r\n    Info:\r\n    main.pony:7:12: Array[U8 val] trn! is not a subtype of Array[U8 val] trn: trn! is not a subcap of trn\r\n      fun f(): Array[U8] iso =>\r\n               ^\r\n```\r\n\r\nChanging the `iso` in `g(consume iso d)` and `g(data: Array[U8] iso)` to `val` or `ref` compiles successfully.\r\n\r\nChanging `let d' = g(consume iso d)` to `let d' = consume iso d` compiles successfully.\r\n\r\nChanging the code to remove the function `f()` like:\r\n\r\n```Pony\r\nactor Main\r\n  new create(env:Env) =>\r\n    let d = recover Array[U8] end\r\n    d.push(4)\r\n    d.push(4)\r\n    d.push(4)\r\n    d.push(4)\r\n    d\r\n\r\n    let d' = g(consume iso d)\r\n\r\n  fun g(data: Array[U8] iso) =>\r\n    None\r\n```\r\n\r\nalso compiles successfully."},"comment":{"url":"https://api.github.com/repos/ponylang/ponyc/issues/comments/312531716","html_url":"https://github.com/ponylang/ponyc/issues/2003#issuecomment-312531716","issue_url":"https://api.github.com/repos/ponylang/ponyc/issues/2003","id":312531716,"user":{"login":"dipinhora","id":11946442,"avatar_url":"https://avatars0.githubusercontent.com/u/11946442?v=3","gravatar_id":"","url":"https://api.github.com/users/dipinhora","html_url":"https://github.com/dipinhora","followers_url":"https://api.github.com/users/dipinhora/followers","following_url":"https://api.github.com/users/dipinhora/following{/other_user}","gists_url":"https://api.github.com/users/dipinhora/gists{/gist_id}","starred_url":"https://api.github.com/users/dipinhora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dipinhora/subscriptions","organizations_url":"https://api.github.com/users/dipinhora/orgs","repos_url":"https://api.github.com/users/dipinhora/repos","events_url":"https://api.github.com/users/dipinhora/events{/privacy}","received_events_url":"https://api.github.com/users/dipinhora/received_events","type":"User","site_admin":false},"created_at":"2017-07-03T01:45:40Z","updated_at":"2017-07-03T01:45:40Z","body":"@jemc Thanks. Much appreciated."}}
{"actor":{"display_login":"dipinhora"}}