diff --git a/topiary/languages/ocaml.scm b/topiary/languages/ocaml.scm index f1857c35..3aa145bc 100644 --- a/topiary/languages/ocaml.scm +++ b/topiary/languages/ocaml.scm @@ -154,6 +154,8 @@ "external" (floating_attribute) "for" + "fun" + "function" "if" "in" "include" @@ -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 diff --git a/topiary/tests/samples/expected/ocaml.ml b/topiary/tests/samples/expected/ocaml.ml index e7735478..01be24c6 100644 --- a/topiary/tests/samples/expected/ocaml.ml +++ b/topiary/tests/samples/expected/ocaml.ml @@ -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- diff --git a/topiary/tests/samples/input/ocaml.ml b/topiary/tests/samples/input/ocaml.ml index ca4a097b..d7c27f17 100644 --- a/topiary/tests/samples/input/ocaml.ml +++ b/topiary/tests/samples/input/ocaml.ml @@ -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-