Skip to content

Commit

Permalink
OCaml spacing error (#536)
Browse files Browse the repository at this point in the history
* Spacing after function keywords.

* [OCaml] open `function_definition` scope more often

---------

Co-authored-by: Nicolas BACQUEY <nicolas.bacquey@tweag.io>
  • Loading branch information
torhovland and nbacquey authored Jul 6, 2023
1 parent 8ffb65c commit 2d72db6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
13 changes: 5 additions & 8 deletions topiary/languages/ocaml.scm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@
"external"
(floating_attribute)
"for"
"fun"
"function"
"if"
"in"
"include"
Expand Down Expand Up @@ -783,18 +785,13 @@
) @end_scope
(#scope_id! "function_definition")
)
(parenthesized_expression
(function_expression
"function" @append_spaced_scoped_softline
) @begin_scope @end_scope
(#scope_id! "function_definition")
)
; The following is the general case, which should happen anywhere except in let bindings
(
(_) @begin_scope
"="? @do_nothing
.
(function_expression
"function" @append_spaced_scoped_softline
) @end_scope
) @begin_scope @end_scope
(#scope_id! "function_definition")
)
(function_expression
Expand Down
18 changes: 18 additions & 0 deletions topiary/tests/samples/expected/ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
(* *)
(**************************************************************************)

(* Issue 529 *)

let id1 = if true then Fun.id else function x -> x

let id2 = if true then Fun.id else function x -> x | y -> y

let id3 =
if true then
Fun.id
else
function x -> x

let id4 = function x -> x

let id5 = if true then Fun.id else function x -> x

let id6 = function x -> x

(* Extensible buffers *)

type t = (* Multi-
Expand Down
19 changes: 19 additions & 0 deletions topiary/tests/samples/input/ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
(* *)
(**************************************************************************)

(* Issue 529 *)

let id1 = if true then Fun.id else function x -> x

let id2 = if true then Fun.id else function x -> x | y -> y

let id3 = if
true
then
Fun.id
else
function x -> x

let id4 = function x -> x

let id5 = if true then Fun.id else function | x -> x

let id6 = function | x -> x

(* Extensible buffers *)

type t = (* Multi-
Expand Down

0 comments on commit 2d72db6

Please # to comment.