Skip to content

Commit

Permalink
flambda-backend: Fix missing parens around local exp in pprintast (#2342
Browse files Browse the repository at this point in the history
)
  • Loading branch information
riaqn authored Mar 7, 2024
1 parent ca8415c commit fa1fdec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion parsing/pprintast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,9 @@ and jane_syntax_expr ctxt attrs f (jexp : Jane_syntax.Expression.t) ~parens =
if parens then pp f "(%a)" (n_ary_function_expr reset_ctxt) x
else n_ary_function_expr ctxt f x
| Jexp_tuple ltexp -> labeled_tuple_expr ctxt f ltexp
| Jexp_modes mexp -> mode_expr ctxt f mexp
| Jexp_modes mexp ->
if parens then pp f "(%a)" (mode_expr ctxt) mexp
else mode_expr ctxt f mexp

and mode_expr ctxt f (mexp : Jane_syntax.Modes.expression) =
match mexp with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module Example = struct
type u = Foo : global_ string * global_ string -> u \
end"

let local_exp = parse expression "let x = foo (local_ x) in local_ y"

let longident = parse longident "No.Longidents.Require.extensions"
let expression = parse expression "[x for x = 1 to 10]"
let pattern = parse pattern "[:_:]"
Expand Down Expand Up @@ -136,6 +138,8 @@ end = struct
let modality_record = test "modality_record" module_expr Example.modality_record
let modality_cstrarg = test "modality_cstrarg" module_expr Example.modality_cstrarg

let local_exp = test "local_exp" expression Example.local_exp

let longident = test "longident" longident Example.longident
let expression = test "expression" expression Example.expression
let pattern = test "pattern" pattern Example.pattern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ modality_cstrarg:
| Foo: global_ string * global_ string -> u
end

local_exp: let x = foo (local_ x) in local_ y

longident: No.Longidents.Require.extensions

expression: [x for x = 1 to 10]
Expand Down Expand Up @@ -82,6 +84,8 @@ modality_cstrarg:
| Foo: global_ string * global_ string -> u
end

local_exp: let x = foo (local_ x) in local_ y

longident: No.Longidents.Require.extensions

expression: [x for x = 1 to 10]
Expand Down

0 comments on commit fa1fdec

Please sign in to comment.