{"action":"created","comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/comments/46135756","id":46135756,"diff_hunk":"@@ -818,9 +820,19 @@ let unify_field_call ctx fa el args ret p inline =\n \t\tList.map fst el,tf,mk_call\n \t| _ ->\n \t\tlet candidates,failures = loop candidates in\n-\t\tlet fail () = match List.rev failures with\n-\t\t\t| err :: _ -> raise err\n-\t\t\t| _ -> assert false\n+\t\tlet fail () =\n+\t\t\tlet failures = List.map (fun (cf,err,p) -> cf,error_msg err,p) failures in\n+\t\t\tbegin match failures with\n+\t\t\t| (_,msg,p) :: failures when List.for_all (fun (_,msg2,_) -> msg = msg2) failures ->\n+\t\t\t\terror msg p\n+\t\t\t| _ ->\n+\t\t\t\tdisplay_error ctx \"Could not find a suitable overload, reasons follow\" p;\n+\t\t\t\tList.iter (fun (cf,msg,p2) ->\n+\t\t\t\t\tdisplay_error ctx (\"Overload resolution failed for \" ^ (s_type (print_context()) cf.cf_type)) p;\n+\t\t\t\t\tdisplay_error ctx msg p2;\n+\t\t\t\t) failures;\n+\t\t\t\terror \"End of overload fail reasons\" p","path":"typer.ml","position":69,"original_position":69,"commit_id":"1cdd38cf9736d9d6bffb0489b2fee7c2ed6307c9","original_commit_id":"1cdd38cf9736d9d6bffb0489b2fee7c2ed6307c9","user":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"body":"Indeed, thanks!","created_at":"2015-11-30T12:09:31Z","updated_at":"2015-11-30T12:09:31Z","html_url":"https://github.com/HaxeFoundation/haxe/pull/4683#discussion_r46135756","pull_request_url":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683","_links":{"self":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/comments/46135756"},"html":{"href":"https://github.com/HaxeFoundation/haxe/pull/4683#discussion_r46135756"},"pull_request":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683"}}},"pull_request":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683","id":52113873,"html_url":"https://github.com/HaxeFoundation/haxe/pull/4683","diff_url":"https://github.com/HaxeFoundation/haxe/pull/4683.diff","patch_url":"https://github.com/HaxeFoundation/haxe/pull/4683.patch","issue_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4683","number":4683,"state":"open","locked":false,"title":"Improved resume","user":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"body":"This pull requests gets rid of `WithTypeResume` and instead adds `in_call_args : bool` to the typing context. If a unification fails while `in_call_args = true`, a `WithTypeError` is raised and handled accordingly.\r\n\r\nThis addresses the fact that not all overload-related unification failures are caused by a direct unification of something against the expected argument type, such as the initial examples in #3452.\r\n\r\nNaturally, we still want to detect if there's something wrong with one of the argument expressions regardless of overloads. For this we simply check if all overload resolution attempts resulted in the exact same error message. By definition this must mean that the error is invariant with regards to the overloads themselves, so we can just give a normal error:\r\n\r\n```haxe\r\nclass Main {\r\n\tstatic function main() {\r\n\t\tf(function(e) {\r\n\t\t\tvar s:String = 12;\r\n\t\t});\r\n\t}\r\n\r\n\t@:overload(function(c:Bool->Void):Void {})\r\n\tstatic function f(c:Int->Void):Void {}\r\n}\r\n```\r\n\r\n```\r\nsrc/Main.hx:4: characters 3-21 : Int should be String\r\nsrc/Main.hx:4: characters 3-21 : For function argument 'c'\r\n```\r\n\r\nAs a bonus, I have also improved overload-related errors by mentioning which attempts failed and why:\r\n\r\n```haxe\r\nclass Main {\r\n\tstatic function main() {\r\n\t\tf(function(e) {\r\n\t\t\tvar s:String = e;\r\n\t\t});\r\n\t}\r\n\r\n\t@:overload(function(c:Bool->Void):Void {})\r\n\tstatic function f(c:Int->Void):Void {}\r\n}\r\n```\r\n\r\n```\r\nsrc/Main.hx:3: lines 3-5 : Could not find a suitable overload, reasons follow\r\nsrc/Main.hx:3: lines 3-5 : Overload resolution failed for c : (Int -> Void) -> Void\r\nsrc/Main.hx:4: characters 3-20 : Int should be String\r\nsrc/Main.hx:4: characters 3-20 : For function argument 'c'\r\nsrc/Main.hx:3: lines 3-5 : Overload resolution failed for c : (Bool -> Void) -> Void\r\nsrc/Main.hx:4: characters 3-20 : Bool should be String\r\nsrc/Main.hx:4: characters 3-20 : For function argument 'c'\r\nsrc/Main.hx:3: lines 3-5 : End of overload fail reasons\r\n```","created_at":"2015-11-30T11:42:52Z","updated_at":"2015-11-30T12:09:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0227a5ddb0f9a9cc720956611e03fc78d5dcfca0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683/commits","review_comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683/comments","review_comment_url":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4683/comments","statuses_url":"https://api.github.com/repos/HaxeFoundation/haxe/statuses/1cdd38cf9736d9d6bffb0489b2fee7c2ed6307c9","head":{"label":"Simn:improved_resume","ref":"improved_resume","sha":"1cdd38cf9736d9d6bffb0489b2fee7c2ed6307c9","user":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"repo":{"id":10294455,"name":"haxe","full_name":"Simn/haxe","owner":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Simn/haxe","description":"","fork":true,"url":"https://api.github.com/repos/Simn/haxe","forks_url":"https://api.github.com/repos/Simn/haxe/forks","keys_url":"https://api.github.com/repos/Simn/haxe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Simn/haxe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Simn/haxe/teams","hooks_url":"https://api.github.com/repos/Simn/haxe/hooks","issue_events_url":"https://api.github.com/repos/Simn/haxe/issues/events{/number}","events_url":"https://api.github.com/repos/Simn/haxe/events","assignees_url":"https://api.github.com/repos/Simn/haxe/assignees{/user}","branches_url":"https://api.github.com/repos/Simn/haxe/branches{/branch}","tags_url":"https://api.github.com/repos/Simn/haxe/tags","blobs_url":"https://api.github.com/repos/Simn/haxe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Simn/haxe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Simn/haxe/git/refs{/sha}","trees_url":"https://api.github.com/repos/Simn/haxe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Simn/haxe/statuses/{sha}","languages_url":"https://api.github.com/repos/Simn/haxe/languages","stargazers_url":"https://api.github.com/repos/Simn/haxe/stargazers","contributors_url":"https://api.github.com/repos/Simn/haxe/contributors","subscribers_url":"https://api.github.com/repos/Simn/haxe/subscribers","subscription_url":"https://api.github.com/repos/Simn/haxe/subscription","commits_url":"https://api.github.com/repos/Simn/haxe/commits{/sha}","git_commits_url":"https://api.github.com/repos/Simn/haxe/git/commits{/sha}","comments_url":"https://api.github.com/repos/Simn/haxe/comments{/number}","issue_comment_url":"https://api.github.com/repos/Simn/haxe/issues/comments{/number}","contents_url":"https://api.github.com/repos/Simn/haxe/contents/{+path}","compare_url":"https://api.github.com/repos/Simn/haxe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Simn/haxe/merges","archive_url":"https://api.github.com/repos/Simn/haxe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Simn/haxe/downloads","issues_url":"https://api.github.com/repos/Simn/haxe/issues{/number}","pulls_url":"https://api.github.com/repos/Simn/haxe/pulls{/number}","milestones_url":"https://api.github.com/repos/Simn/haxe/milestones{/number}","notifications_url":"https://api.github.com/repos/Simn/haxe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Simn/haxe/labels{/name}","releases_url":"https://api.github.com/repos/Simn/haxe/releases{/id}","created_at":"2013-05-26T06:34:40Z","updated_at":"2015-07-31T13:28:46Z","pushed_at":"2015-11-30T11:33:31Z","git_url":"git://github.com/Simn/haxe.git","ssh_url":"git@github.com:Simn/haxe.git","clone_url":"https://github.com/Simn/haxe.git","svn_url":"https://github.com/Simn/haxe","homepage":null,"size":45924,"stargazers_count":4,"watchers_count":4,"language":"Haxe","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":4,"default_branch":"development"}},"base":{"label":"HaxeFoundation:development","ref":"development","sha":"00a3af7ae01369adb3e699305ad71bb44edef02b","user":{"login":"HaxeFoundation","id":3826779,"avatar_url":"https://avatars.githubusercontent.com/u/3826779?v=3","gravatar_id":"","url":"https://api.github.com/users/HaxeFoundation","html_url":"https://github.com/HaxeFoundation","followers_url":"https://api.github.com/users/HaxeFoundation/followers","following_url":"https://api.github.com/users/HaxeFoundation/following{/other_user}","gists_url":"https://api.github.com/users/HaxeFoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/HaxeFoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HaxeFoundation/subscriptions","organizations_url":"https://api.github.com/users/HaxeFoundation/orgs","repos_url":"https://api.github.com/users/HaxeFoundation/repos","events_url":"https://api.github.com/users/HaxeFoundation/events{/privacy}","received_events_url":"https://api.github.com/users/HaxeFoundation/received_events","type":"Organization","site_admin":false},"repo":{"id":10282042,"name":"haxe","full_name":"HaxeFoundation/haxe","owner":{"login":"HaxeFoundation","id":3826779,"avatar_url":"https://avatars.githubusercontent.com/u/3826779?v=3","gravatar_id":"","url":"https://api.github.com/users/HaxeFoundation","html_url":"https://github.com/HaxeFoundation","followers_url":"https://api.github.com/users/HaxeFoundation/followers","following_url":"https://api.github.com/users/HaxeFoundation/following{/other_user}","gists_url":"https://api.github.com/users/HaxeFoundation/gists{/gist_id}","starred_url":"https://api.github.com/users/HaxeFoundation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HaxeFoundation/subscriptions","organizations_url":"https://api.github.com/users/HaxeFoundation/orgs","repos_url":"https://api.github.com/users/HaxeFoundation/repos","events_url":"https://api.github.com/users/HaxeFoundation/events{/privacy}","received_events_url":"https://api.github.com/users/HaxeFoundation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HaxeFoundation/haxe","description":"Haxe - The Cross-Platform Toolkit","fork":false,"url":"https://api.github.com/repos/HaxeFoundation/haxe","forks_url":"https://api.github.com/repos/HaxeFoundation/haxe/forks","keys_url":"https://api.github.com/repos/HaxeFoundation/haxe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HaxeFoundation/haxe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HaxeFoundation/haxe/teams","hooks_url":"https://api.github.com/repos/HaxeFoundation/haxe/hooks","issue_events_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/events{/number}","events_url":"https://api.github.com/repos/HaxeFoundation/haxe/events","assignees_url":"https://api.github.com/repos/HaxeFoundation/haxe/assignees{/user}","branches_url":"https://api.github.com/repos/HaxeFoundation/haxe/branches{/branch}","tags_url":"https://api.github.com/repos/HaxeFoundation/haxe/tags","blobs_url":"https://api.github.com/repos/HaxeFoundation/haxe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HaxeFoundation/haxe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HaxeFoundation/haxe/git/refs{/sha}","trees_url":"https://api.github.com/repos/HaxeFoundation/haxe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HaxeFoundation/haxe/statuses/{sha}","languages_url":"https://api.github.com/repos/HaxeFoundation/haxe/languages","stargazers_url":"https://api.github.com/repos/HaxeFoundation/haxe/stargazers","contributors_url":"https://api.github.com/repos/HaxeFoundation/haxe/contributors","subscribers_url":"https://api.github.com/repos/HaxeFoundation/haxe/subscribers","subscription_url":"https://api.github.com/repos/HaxeFoundation/haxe/subscription","commits_url":"https://api.github.com/repos/HaxeFoundation/haxe/commits{/sha}","git_commits_url":"https://api.github.com/repos/HaxeFoundation/haxe/git/commits{/sha}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/comments{/number}","issue_comment_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/comments{/number}","contents_url":"https://api.github.com/repos/HaxeFoundation/haxe/contents/{+path}","compare_url":"https://api.github.com/repos/HaxeFoundation/haxe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HaxeFoundation/haxe/merges","archive_url":"https://api.github.com/repos/HaxeFoundation/haxe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HaxeFoundation/haxe/downloads","issues_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues{/number}","pulls_url":"https://api.github.com/repos/HaxeFoundation/haxe/pulls{/number}","milestones_url":"https://api.github.com/repos/HaxeFoundation/haxe/milestones{/number}","notifications_url":"https://api.github.com/repos/HaxeFoundation/haxe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/labels{/name}","releases_url":"https://api.github.com/repos/HaxeFoundation/haxe/releases{/id}","created_at":"2013-05-25T09:20:11Z","updated_at":"2015-11-30T03:19:21Z","pushed_at":"2015-11-30T11:42:53Z","git_url":"git://github.com/HaxeFoundation/haxe.git","ssh_url":"git@github.com:HaxeFoundation/haxe.git","clone_url":"https://github.com/HaxeFoundation/haxe.git","svn_url":"https://github.com/HaxeFoundation/haxe","homepage":"http://haxe.org","size":82263,"stargazers_count":1140,"watchers_count":1140,"language":"Haxe","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":252,"mirror_url":null,"open_issues_count":417,"forks":252,"open_issues":417,"watchers":1140,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683"},"html":{"href":"https://github.com/HaxeFoundation/haxe/pull/4683"},"issue":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4683"},"comments":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/issues/4683/comments"},"review_comments":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683/comments"},"review_comment":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/pulls/4683/commits"},"statuses":{"href":"https://api.github.com/repos/HaxeFoundation/haxe/statuses/1cdd38cf9736d9d6bffb0489b2fee7c2ed6307c9"}}}}