You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ocamlformat seems to have an issue processing certain let-bindings that contain first-class modules as optional parameters.
Specifically, it fails when encountering a let-binding that takes an optional module argument with a default value, such as in scenario 2 below.
Let-bindings containing optional module parameters without a default value, such a scenario 1, are unaffected. Let-bindings containing non-optional module parameters are also fine.
Error output
ocamlformat version 0.12 with default configuration
ocamlformat: Cannot process "example.ml".
Please report this bug at https://github.com/ocaml-ppx/ocamlformat/issues.
BUG: generating invalid ocaml syntax.
Reproduction steps
module type X_typ=sigvalf : int -> intendmoduleX_add_one : X_typ=structlet f = (+) 1end(* Scenario 1: No issue with no default value *)lethelper?x=match x with|Some (module X:X_typ) -> X.f
|None -> X_add_one.f
(* Scenario 2: Fails with "BUG: generating invalid ocaml syntax." *)lethelper?x:((module X)=(moduleX_add_one:X_typ)) =X.f
let()=Printf.printf "%d\n" (helper 41)
The text was updated successfully, but these errors were encountered:
Previously, some module patterns would not be parenthesized.
This was a bug because module patterns must always be
parenthesized per the language spec (8.6).
Fixesocaml-ppx#1201
cbarcenas
added a commit
to cbarcenas/ocamlformat
that referenced
this issue
Jan 3, 2020
Always use Ast.parenze_pat to decide whether to
parenthesize patterns appearing in function arguments.
Previously, patterns appearing in optional arguments with
default values would never be parenthesized. This was a bug
because some patterns (e.g. module patterns) must always be
parenthesized per the language spec.
Fixesocaml-ppx#1201
ocamlformat
seems to have an issue processing certain let-bindings that contain first-class modules as optional parameters.Specifically, it fails when encountering a let-binding that takes an optional module argument with a default value, such as in scenario 2 below.
Let-bindings containing optional module parameters without a default value, such a scenario 1, are unaffected. Let-bindings containing non-optional module parameters are also fine.
Error output
ocamlformat version 0.12 with default configuration
Reproduction steps
The text was updated successfully, but these errors were encountered: