Organisationsocaml-ppxocamlformatpull/2651Build History

Build History for pull/2651

Builds (2)
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).
75ff31
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).
f1c296