-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate better asts for function bindings
Currently: ```ocaml let foo1 : _ = function () -> () let foo2 x : _ = function () -> () ``` are parsed into these value_bindings: ```ocaml (* foo1 *) { pvb_args = [] ; pvb_constraint = Some "_" ; pvb_body = Pfunction_cases ... } (* foo2 *) { pvb_args = ["x"] ; pvb_constraint = Some "_" ; pvb_body = Pfunction_cases ... } ``` I expect instead: ```ocaml (* foo1 *) { pvb_args = [] ; pvb_constraint = Some "_" ; pvb_body = Pfunction_body (Pexp_function ([], None, Pfunction_cases ...)) } (* foo2 (no changes here) *) { pvb_args = ["x"] ; pvb_constraint = Some "_" ; pvb_body = Pfunction_cases ... } ``` I think the ast for foo1: - is confusing - creates a needless distinction between `let f : _ = function () -> ()` vs `let f : _ = (function () -> ())`, unlike, say, `1 + function () -> ()` vs `1 + (function () -> ())`. - is essentially an invariant violation. The type of value_bindings in ocamlformat should be understood to be the union of a non-function let-binding + an inline pexp_function node. But the node for foo1 corresponds to the syntax of neither a non-function let-binding (because of body = Pfunction_cases _), nor an inline pexp_function (because pexp_function can't have a type_constraint with an empty list of params).
- Loading branch information
Showing
7 changed files
with
26 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters