{"action":"created","issue":{"url":"https://api.github.com/repos/savonet/liquidsoap/issues/1018","repository_url":"https://api.github.com/repos/savonet/liquidsoap","labels_url":"https://api.github.com/repos/savonet/liquidsoap/issues/1018/labels{/name}","comments_url":"https://api.github.com/repos/savonet/liquidsoap/issues/1018/comments","events_url":"https://api.github.com/repos/savonet/liquidsoap/issues/1018/events","html_url":"https://github.com/savonet/liquidsoap/issues/1018","id":516384264,"node_id":"MDU6SXNzdWU1MTYzODQyNjQ=","number":1018,"title":"Cannot make recursive functions with optional arguments.","user":{"login":"smimram","id":2012073,"node_id":"MDQ6VXNlcjIwMTIwNzM=","avatar_url":"https://avatars0.githubusercontent.com/u/2012073?v=4","gravatar_id":"","url":"https://api.github.com/users/smimram","html_url":"https://github.com/smimram","followers_url":"https://api.github.com/users/smimram/followers","following_url":"https://api.github.com/users/smimram/following{/other_user}","gists_url":"https://api.github.com/users/smimram/gists{/gist_id}","starred_url":"https://api.github.com/users/smimram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smimram/subscriptions","organizations_url":"https://api.github.com/users/smimram/orgs","repos_url":"https://api.github.com/users/smimram/repos","events_url":"https://api.github.com/users/smimram/events{/privacy}","received_events_url":"https://api.github.com/users/smimram/received_events","type":"User","site_admin":false},"labels":[{"id":99524082,"node_id":"MDU6TGFiZWw5OTUyNDA4Mg==","url":"https://api.github.com/repos/savonet/liquidsoap/labels/bug","name":"bug","color":"eb6420","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-11-01T22:45:57Z","updated_at":"2019-11-13T13:14:43Z","closed_at":null,"author_association":"MEMBER","body":"Consider the following code:\r\n```\r\ndef rec fact(~n=0)\r\n  if n == 0 then\r\n    1\r\n  else\r\n    n * fact(n=(n-1))\r\n  end\r\nend\r\n```\r\nIt gives rise to the error\r\n```\r\nError 5: this value has type\r\n  (n : _, ...) -> _ (inferred at line 7, char 8-13)\r\nbut it should be a supertype of the type of the value at line 3 char 0 - line 9 char 3\r\n  (?n : _) -> _\r\n```\r\nbecause when the function `fact` is applied to the label `n` in the middle, we infer that it has a non-optional argument labeled `n`: we cannot guess that it is going to be optional yet...\r\n\r\nThis means in practice that we cannot make recursive functions with optional arguments (and I have more convincing examples than factorial...).\r\n\r\nI don't see a way out without introducing a new syntax for using optional arguments when we really want to mean that they are optional. In OCaml, the way out is to use option types, which we don't have...\r\n\r\n@toots any idea / comment ?"},"comment":{"url":"https://api.github.com/repos/savonet/liquidsoap/issues/comments/553398889","html_url":"https://github.com/savonet/liquidsoap/issues/1018#issuecomment-553398889","issue_url":"https://api.github.com/repos/savonet/liquidsoap/issues/1018","id":553398889,"node_id":"MDEyOklzc3VlQ29tbWVudDU1MzM5ODg4OQ==","user":{"login":"smimram","id":2012073,"node_id":"MDQ6VXNlcjIwMTIwNzM=","avatar_url":"https://avatars0.githubusercontent.com/u/2012073?v=4","gravatar_id":"","url":"https://api.github.com/users/smimram","html_url":"https://github.com/smimram","followers_url":"https://api.github.com/users/smimram/followers","following_url":"https://api.github.com/users/smimram/following{/other_user}","gists_url":"https://api.github.com/users/smimram/gists{/gist_id}","starred_url":"https://api.github.com/users/smimram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smimram/subscriptions","organizations_url":"https://api.github.com/users/smimram/orgs","repos_url":"https://api.github.com/users/smimram/repos","events_url":"https://api.github.com/users/smimram/events{/privacy}","received_events_url":"https://api.github.com/users/smimram/received_events","type":"User","site_admin":false},"created_at":"2019-11-13T13:14:43Z","updated_at":"2019-11-13T13:14:43Z","author_association":"MEMBER","body":"BTW, it turns out that this is working in OCaml, which means that some magic is at work :)"}}
{"actor":{"display_login":"smimram"}}