{"action":"created","comment":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/comments/88098723","pull_request_review_id":8682369,"id":88098723,"diff_hunk":"@@ -73,6 +73,15 @@ module Typ :\n     val extension: ?loc:loc -> ?attrs:attrs -> extension -> core_type\n \n     val force_poly: core_type -> core_type\n+\n+    val varify_constructors: str list -> core_type -> core_type\n+    (** [varify_constructors newtypes te] is type expression [te], of which\n+        any of nullary type constructor [tc] is replaced by type variable of\n+        the same name, if [tc]'s name appears in [newtypes].\n+        Raise [Syntaxerr.Variable_in_scope] if any type variable inside [te]\n+        appears in [newtypes].\n+        @since 4.05\n+     *)","path":"parsing/ast_helper.mli","position":12,"original_position":12,"commit_id":"85b57947e95e95f9108c05743ae99b2d3db5dace","original_commit_id":"85b57947e95e95f9108c05743ae99b2d3db5dace","user":{"login":"Octachron","id":7689388,"avatar_url":"https://avatars.githubusercontent.com/u/7689388?v=3","gravatar_id":"","url":"https://api.github.com/users/Octachron","html_url":"https://github.com/Octachron","followers_url":"https://api.github.com/users/Octachron/followers","following_url":"https://api.github.com/users/Octachron/following{/other_user}","gists_url":"https://api.github.com/users/Octachron/gists{/gist_id}","starred_url":"https://api.github.com/users/Octachron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Octachron/subscriptions","organizations_url":"https://api.github.com/users/Octachron/orgs","repos_url":"https://api.github.com/users/Octachron/repos","events_url":"https://api.github.com/users/Octachron/events{/privacy}","received_events_url":"https://api.github.com/users/Octachron/received_events","type":"User","site_admin":false},"body":"May I suggest a slightly different wording?\r\n``` [varify_constructors newtypes te] is the type expression [te'], \r\n     where all nullary type constructors whose name appears in [newtypes]\r\n     have been replaced by a type variable of the same name.\r\n     Raise [Syntaxerr.Variable_in_scope] if any type variable inside [te]\r\n     appears in [newtypes].\r\n     @since 4.05\r\n     *)\r\n```\r\nN.B: Please feel free to ignore or improve upon this suggestion.","created_at":"2016-11-15T19:51:42Z","updated_at":"2016-11-15T19:51:42Z","html_url":"https://github.com/ocaml/ocaml/pull/915#discussion_r88098723","pull_request_url":"https://api.github.com/repos/ocaml/ocaml/pulls/915","_links":{"self":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/comments/88098723"},"html":{"href":"https://github.com/ocaml/ocaml/pull/915#discussion_r88098723"},"pull_request":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/915"}}},"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/915","id":93525965,"html_url":"https://github.com/ocaml/ocaml/pull/915","diff_url":"https://github.com/ocaml/ocaml/pull/915.diff","patch_url":"https://github.com/ocaml/ocaml/pull/915.patch","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/915","number":915,"state":"open","locked":false,"title":"more -dsource bug fix","user":{"login":"objmagic","id":3656079,"avatar_url":"https://avatars.githubusercontent.com/u/3656079?v=3","gravatar_id":"","url":"https://api.github.com/users/objmagic","html_url":"https://github.com/objmagic","followers_url":"https://api.github.com/users/objmagic/followers","following_url":"https://api.github.com/users/objmagic/following{/other_user}","gists_url":"https://api.github.com/users/objmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/objmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/objmagic/subscriptions","organizations_url":"https://api.github.com/users/objmagic/orgs","repos_url":"https://api.github.com/users/objmagic/repos","events_url":"https://api.github.com/users/objmagic/events{/privacy}","received_events_url":"https://api.github.com/users/objmagic/received_events","type":"User","site_admin":false},"body":"This PR is a follow-up of https://github.com/ocaml/ocaml/pull/539, which aims to fix two more corner case `-dsource`([pprintast.ml](https://github.com/ocaml/ocaml/blob/trunk/parsing/pprintast.ml)) bugs. \r\n\r\nCf. [Mantis 7200](https://caml.inria.fr/mantis/view.php?id=7200)\r\n\r\n### Bug 1: GADT exp\r\n\r\nParse tree of `let f: type a'.a' = assert false` is incorrectly printed to `let f : 'a' . 'a' = fun (type a') -> (assert false : a')`. This bug happens since `a'` is a valid new type name according to [lexing rule](https://github.com/ocaml/ocaml/blob/trunk/parsing/lexer.mll#L340)\r\n\r\n**Solution**: _really_ pretty-print GADT let-expression by restoring the desugared GADT let-expression. After this PR, the above example will have output `let f : type a'.a' = assert false`\r\n\r\n### Bug 2: Polymorphic method\r\n\r\nParse tree of\r\n\r\n```OCaml\r\nclass ['a] c () = object\r\n  constraint 'a = < .. > -> unit\r\n  method m  = (fun x -> () : 'a)\r\nend\r\n```\r\n\r\nis incorrectly printed to\r\n\r\n```OCaml\r\nclass ['a] c () =\r\n  object constraint 'a = < .. > -> unit method m : 'a = fun x  -> () end\r\n```\r\n\r\nThis is wrong because now two classes have different signatures. The input has signatures\r\n\r\n```OCaml\r\nclass ['a] c : unit ->\r\n  object constraint 'a = (< .. > as 'b) -> unit method m : 'b -> unit end\r\n```\r\n\r\nbut the output has\r\n```OCaml\r\nclass ['a] c :\r\n    unit -> object constraint 'a = (< .. > as 'b) -> unit method m : 'a end\r\n```\r\n\r\n**Solution**: delete the part that incorrectly optimizes pretty-printing in this situation.\r\n\r\n```diff\r\n-    | Pexp_constraint (e,t1),Ppat_var {txt;_} ->\r\n-      pp f \"%a@;:@ %a@;=@;%a\" protect_ident txt\r\n-        (core_type ctxt) t1 (expression ctxt) e\r\n```\r\n\r\ncc @alainfrisch ","created_at":"2016-11-14T08:36:19Z","updated_at":"2016-11-15T19:51:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d40b99e03eca47f791fd07a460440218aa93970","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ocaml/ocaml/pulls/915/commits","review_comments_url":"https://api.github.com/repos/ocaml/ocaml/pulls/915/comments","review_comment_url":"https://api.github.com/repos/ocaml/ocaml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/915/comments","statuses_url":"https://api.github.com/repos/ocaml/ocaml/statuses/85b57947e95e95f9108c05743ae99b2d3db5dace","head":{"label":"objmagic:more-pprintast-fix","ref":"more-pprintast-fix","sha":"85b57947e95e95f9108c05743ae99b2d3db5dace","user":{"login":"objmagic","id":3656079,"avatar_url":"https://avatars.githubusercontent.com/u/3656079?v=3","gravatar_id":"","url":"https://api.github.com/users/objmagic","html_url":"https://github.com/objmagic","followers_url":"https://api.github.com/users/objmagic/followers","following_url":"https://api.github.com/users/objmagic/following{/other_user}","gists_url":"https://api.github.com/users/objmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/objmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/objmagic/subscriptions","organizations_url":"https://api.github.com/users/objmagic/orgs","repos_url":"https://api.github.com/users/objmagic/repos","events_url":"https://api.github.com/users/objmagic/events{/privacy}","received_events_url":"https://api.github.com/users/objmagic/received_events","type":"User","site_admin":false},"repo":{"id":41222726,"name":"ocaml","full_name":"objmagic/ocaml","owner":{"login":"objmagic","id":3656079,"avatar_url":"https://avatars.githubusercontent.com/u/3656079?v=3","gravatar_id":"","url":"https://api.github.com/users/objmagic","html_url":"https://github.com/objmagic","followers_url":"https://api.github.com/users/objmagic/followers","following_url":"https://api.github.com/users/objmagic/following{/other_user}","gists_url":"https://api.github.com/users/objmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/objmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/objmagic/subscriptions","organizations_url":"https://api.github.com/users/objmagic/orgs","repos_url":"https://api.github.com/users/objmagic/repos","events_url":"https://api.github.com/users/objmagic/events{/privacy}","received_events_url":"https://api.github.com/users/objmagic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/objmagic/ocaml","description":"Read-only mirror of INRIA SVN","fork":true,"url":"https://api.github.com/repos/objmagic/ocaml","forks_url":"https://api.github.com/repos/objmagic/ocaml/forks","keys_url":"https://api.github.com/repos/objmagic/ocaml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/objmagic/ocaml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/objmagic/ocaml/teams","hooks_url":"https://api.github.com/repos/objmagic/ocaml/hooks","issue_events_url":"https://api.github.com/repos/objmagic/ocaml/issues/events{/number}","events_url":"https://api.github.com/repos/objmagic/ocaml/events","assignees_url":"https://api.github.com/repos/objmagic/ocaml/assignees{/user}","branches_url":"https://api.github.com/repos/objmagic/ocaml/branches{/branch}","tags_url":"https://api.github.com/repos/objmagic/ocaml/tags","blobs_url":"https://api.github.com/repos/objmagic/ocaml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/objmagic/ocaml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/objmagic/ocaml/git/refs{/sha}","trees_url":"https://api.github.com/repos/objmagic/ocaml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/objmagic/ocaml/statuses/{sha}","languages_url":"https://api.github.com/repos/objmagic/ocaml/languages","stargazers_url":"https://api.github.com/repos/objmagic/ocaml/stargazers","contributors_url":"https://api.github.com/repos/objmagic/ocaml/contributors","subscribers_url":"https://api.github.com/repos/objmagic/ocaml/subscribers","subscription_url":"https://api.github.com/repos/objmagic/ocaml/subscription","commits_url":"https://api.github.com/repos/objmagic/ocaml/commits{/sha}","git_commits_url":"https://api.github.com/repos/objmagic/ocaml/git/commits{/sha}","comments_url":"https://api.github.com/repos/objmagic/ocaml/comments{/number}","issue_comment_url":"https://api.github.com/repos/objmagic/ocaml/issues/comments{/number}","contents_url":"https://api.github.com/repos/objmagic/ocaml/contents/{+path}","compare_url":"https://api.github.com/repos/objmagic/ocaml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/objmagic/ocaml/merges","archive_url":"https://api.github.com/repos/objmagic/ocaml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/objmagic/ocaml/downloads","issues_url":"https://api.github.com/repos/objmagic/ocaml/issues{/number}","pulls_url":"https://api.github.com/repos/objmagic/ocaml/pulls{/number}","milestones_url":"https://api.github.com/repos/objmagic/ocaml/milestones{/number}","notifications_url":"https://api.github.com/repos/objmagic/ocaml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/objmagic/ocaml/labels{/name}","releases_url":"https://api.github.com/repos/objmagic/ocaml/releases{/id}","deployments_url":"https://api.github.com/repos/objmagic/ocaml/deployments","created_at":"2015-08-22T20:10:41Z","updated_at":"2015-12-21T10:19:15Z","pushed_at":"2016-11-15T17:08:57Z","git_url":"git://github.com/objmagic/ocaml.git","ssh_url":"git@github.com:objmagic/ocaml.git","clone_url":"https://github.com/objmagic/ocaml.git","svn_url":"https://github.com/objmagic/ocaml","homepage":null,"size":209829,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"mainpage"}},"base":{"label":"ocaml:trunk","ref":"trunk","sha":"6439ebdf7025579ccb3fba7eab94a27ff6edbfc5","user":{"login":"ocaml","id":1841483,"avatar_url":"https://avatars.githubusercontent.com/u/1841483?v=3","gravatar_id":"","url":"https://api.github.com/users/ocaml","html_url":"https://github.com/ocaml","followers_url":"https://api.github.com/users/ocaml/followers","following_url":"https://api.github.com/users/ocaml/following{/other_user}","gists_url":"https://api.github.com/users/ocaml/gists{/gist_id}","starred_url":"https://api.github.com/users/ocaml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocaml/subscriptions","organizations_url":"https://api.github.com/users/ocaml/orgs","repos_url":"https://api.github.com/users/ocaml/repos","events_url":"https://api.github.com/users/ocaml/events{/privacy}","received_events_url":"https://api.github.com/users/ocaml/received_events","type":"Organization","site_admin":false},"repo":{"id":6786166,"name":"ocaml","full_name":"ocaml/ocaml","owner":{"login":"ocaml","id":1841483,"avatar_url":"https://avatars.githubusercontent.com/u/1841483?v=3","gravatar_id":"","url":"https://api.github.com/users/ocaml","html_url":"https://github.com/ocaml","followers_url":"https://api.github.com/users/ocaml/followers","following_url":"https://api.github.com/users/ocaml/following{/other_user}","gists_url":"https://api.github.com/users/ocaml/gists{/gist_id}","starred_url":"https://api.github.com/users/ocaml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocaml/subscriptions","organizations_url":"https://api.github.com/users/ocaml/orgs","repos_url":"https://api.github.com/users/ocaml/repos","events_url":"https://api.github.com/users/ocaml/events{/privacy}","received_events_url":"https://api.github.com/users/ocaml/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ocaml/ocaml","description":"The core OCaml system: compilers, runtime system, base libraries","fork":false,"url":"https://api.github.com/repos/ocaml/ocaml","forks_url":"https://api.github.com/repos/ocaml/ocaml/forks","keys_url":"https://api.github.com/repos/ocaml/ocaml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ocaml/ocaml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ocaml/ocaml/teams","hooks_url":"https://api.github.com/repos/ocaml/ocaml/hooks","issue_events_url":"https://api.github.com/repos/ocaml/ocaml/issues/events{/number}","events_url":"https://api.github.com/repos/ocaml/ocaml/events","assignees_url":"https://api.github.com/repos/ocaml/ocaml/assignees{/user}","branches_url":"https://api.github.com/repos/ocaml/ocaml/branches{/branch}","tags_url":"https://api.github.com/repos/ocaml/ocaml/tags","blobs_url":"https://api.github.com/repos/ocaml/ocaml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ocaml/ocaml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ocaml/ocaml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ocaml/ocaml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ocaml/ocaml/statuses/{sha}","languages_url":"https://api.github.com/repos/ocaml/ocaml/languages","stargazers_url":"https://api.github.com/repos/ocaml/ocaml/stargazers","contributors_url":"https://api.github.com/repos/ocaml/ocaml/contributors","subscribers_url":"https://api.github.com/repos/ocaml/ocaml/subscribers","subscription_url":"https://api.github.com/repos/ocaml/ocaml/subscription","commits_url":"https://api.github.com/repos/ocaml/ocaml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ocaml/ocaml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ocaml/ocaml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ocaml/ocaml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ocaml/ocaml/contents/{+path}","compare_url":"https://api.github.com/repos/ocaml/ocaml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ocaml/ocaml/merges","archive_url":"https://api.github.com/repos/ocaml/ocaml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ocaml/ocaml/downloads","issues_url":"https://api.github.com/repos/ocaml/ocaml/issues{/number}","pulls_url":"https://api.github.com/repos/ocaml/ocaml/pulls{/number}","milestones_url":"https://api.github.com/repos/ocaml/ocaml/milestones{/number}","notifications_url":"https://api.github.com/repos/ocaml/ocaml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ocaml/ocaml/labels{/name}","releases_url":"https://api.github.com/repos/ocaml/ocaml/releases{/id}","deployments_url":"https://api.github.com/repos/ocaml/ocaml/deployments","created_at":"2012-11-20T22:18:22Z","updated_at":"2016-11-15T11:16:29Z","pushed_at":"2016-11-15T17:08:57Z","git_url":"git://github.com/ocaml/ocaml.git","ssh_url":"git@github.com:ocaml/ocaml.git","clone_url":"https://github.com/ocaml/ocaml.git","svn_url":"https://github.com/ocaml/ocaml","homepage":"","size":255218,"stargazers_count":1003,"watchers_count":1003,"language":"OCaml","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":309,"mirror_url":null,"open_issues_count":165,"forks":309,"open_issues":165,"watchers":1003,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/915"},"html":{"href":"https://github.com/ocaml/ocaml/pull/915"},"issue":{"href":"https://api.github.com/repos/ocaml/ocaml/issues/915"},"comments":{"href":"https://api.github.com/repos/ocaml/ocaml/issues/915/comments"},"review_comments":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/915/comments"},"review_comment":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/915/commits"},"statuses":{"href":"https://api.github.com/repos/ocaml/ocaml/statuses/85b57947e95e95f9108c05743ae99b2d3db5dace"}}}}
{"actor":{"display_login":"Octachron"}}