{"action":"created","issue":{"url":"https://api.github.com/repos/proper-testing/proper/issues/184","repository_url":"https://api.github.com/repos/proper-testing/proper","labels_url":"https://api.github.com/repos/proper-testing/proper/issues/184/labels{/name}","comments_url":"https://api.github.com/repos/proper-testing/proper/issues/184/comments","events_url":"https://api.github.com/repos/proper-testing/proper/issues/184/events","html_url":"https://github.com/proper-testing/proper/pull/184","id":384019855,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMzM4ODI3","number":184,"title":"Introduce a more informative cant_generate error","user":{"login":"robertoaloi","id":91769,"node_id":"MDQ6VXNlcjkxNzY5","avatar_url":"https://avatars1.githubusercontent.com/u/91769?v=4","gravatar_id":"","url":"https://api.github.com/users/robertoaloi","html_url":"https://github.com/robertoaloi","followers_url":"https://api.github.com/users/robertoaloi/followers","following_url":"https://api.github.com/users/robertoaloi/following{/other_user}","gists_url":"https://api.github.com/users/robertoaloi/gists{/gist_id}","starred_url":"https://api.github.com/users/robertoaloi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertoaloi/subscriptions","organizations_url":"https://api.github.com/users/robertoaloi/orgs","repos_url":"https://api.github.com/users/robertoaloi/repos","events_url":"https://api.github.com/users/robertoaloi/events{/privacy}","received_events_url":"https://api.github.com/users/robertoaloi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-11-24T20:35:35Z","updated_at":"2018-11-27T09:50:31Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/proper-testing/proper/pulls/184","html_url":"https://github.com/proper-testing/proper/pull/184","diff_url":"https://github.com/proper-testing/proper/pull/184.diff","patch_url":"https://github.com/proper-testing/proper/pull/184.patch"},"body":"This PR attempts to address the issue #183 by introducing a more informative _cant_generate_ error in case of failure of the random instance generation subsystem due to a strict constraint (e.g. via a `?SUCHTHAT` macro). This is particularly useful for test modules defining a big number of constraints, where identifying the root cause of a failing constraint can be tricky. As a trivial example, given the following module, which contains an _impossible_ generator (`gen_2/0`):\r\n\r\n```erlang\r\n-module(test).\r\n-include_lib(\"proper/include/proper.hrl\").\r\n\r\ngen_1() ->\r\n  ?SUCHTHAT(A, pos_integer(), A > 0).\r\n\r\ngen_2() ->\r\n  ?SUCHTHAT(B, pos_integer(), B < 0).\r\n\r\nprop() ->\r\n  ?FORALL({A, B}, {gen_1(), gen_2()}, A =:= B).\r\n```\r\n\r\nThe current output from proper is:\r\n\r\n```erl\r\n2> proper:quickcheck(test:prop()).\r\n\r\nError: Couldn't produce an instance that satisfies all strict constraints after 50 tries.\r\n{error,cant_generate}\r\n```\r\n\r\nThis leaves the user in doubt if the error refers to the first or the second occorrence of `?SUCHTHAT`.\r\n\r\nWith the proposed patch, the root cause of the issue becomes more obvious:\r\n\r\n```erl\r\nError: Couldn't produce an instance that satisfies all strict constraints from test:'-gen_2/0-fun-0-' after 50 tries.\r\n{error,\r\n    {cant_generate,\r\n        {'$type',\r\n            [{env,{1,inf}},\r\n             {generator,{typed,#Fun<proper_types.13.103056237>}},\r\n             {is_instance,{typed,#Fun<proper_types.14.103056237>}},\r\n             {shrinkers,[#Fun<proper_types.15.103056237>]},\r\n             {kind,basic},\r\n             {constraints,[{#Fun<test.1.106658561>,true}]}]}}}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/proper-testing/proper/issues/comments/441995563","html_url":"https://github.com/proper-testing/proper/pull/184#issuecomment-441995563","issue_url":"https://api.github.com/repos/proper-testing/proper/issues/184","id":441995563,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTk5NTU2Mw==","user":{"login":"kostis","id":165033,"node_id":"MDQ6VXNlcjE2NTAzMw==","avatar_url":"https://avatars1.githubusercontent.com/u/165033?v=4","gravatar_id":"","url":"https://api.github.com/users/kostis","html_url":"https://github.com/kostis","followers_url":"https://api.github.com/users/kostis/followers","following_url":"https://api.github.com/users/kostis/following{/other_user}","gists_url":"https://api.github.com/users/kostis/gists{/gist_id}","starred_url":"https://api.github.com/users/kostis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kostis/subscriptions","organizations_url":"https://api.github.com/users/kostis/orgs","repos_url":"https://api.github.com/users/kostis/repos","events_url":"https://api.github.com/users/kostis/events{/privacy}","received_events_url":"https://api.github.com/users/kostis/received_events","type":"User","site_admin":false},"created_at":"2018-11-27T09:50:31Z","updated_at":"2018-11-27T09:50:31Z","author_association":"COLLABORATOR","body":"On second thought, perhaps calling `eunit_lib:fun_parent` directly will do the trick."}}
{"actor":{"display_login":"kostis"}}