From e9b0a926d6411e88d8bca8ce158610f093951eb1 Mon Sep 17 00:00:00 2001 From: Guillaume Petiot Date: Thu, 29 Aug 2019 22:04:22 +0700 Subject: [PATCH] Fix crash on extension sequence (#992) --- src/Fmt_ast.ml | 3 ++- test/passing/extensions-indent.ml.ref | 2 ++ test/passing/extensions-sugar_always.ml.ref | 2 ++ test/passing/extensions.ml | 2 ++ test/passing/extensions.ml.ref | 2 ++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Fmt_ast.ml b/src/Fmt_ast.ml index e46c948a57..576a762ec1 100644 --- a/src/Fmt_ast.ml +++ b/src/Fmt_ast.ml @@ -2251,7 +2251,8 @@ and fmt_expression c ?(box = true) ?pro ?epi ?eol ?parens ?(indent_wrap = 0) ; pstr_loc= _ } ] ) when List.is_empty pexp_attributes && ( Poly.(c.conf.extension_sugar = `Always) - || Source.extension_using_sugar ~name:ext ~payload:e1 ) -> + || Source.extension_using_sugar ~name:ext ~payload:e1 + && List.length (Sugar.sequence c.conf c.cmts xexp) > 1 ) -> fmt_sequence c parens width xexp pexp_loc fmt_atrs ~ext | Pexp_sequence _ -> fmt_sequence c parens width xexp pexp_loc fmt_atrs ?ext diff --git a/test/passing/extensions-indent.ml.ref b/test/passing/extensions-indent.ml.ref index bfda087163..2cfc293e33 100644 --- a/test/passing/extensions-indent.ml.ref +++ b/test/passing/extensions-indent.ml.ref @@ -177,3 +177,5 @@ let _ = [%ext let+ a = b in c] + +let _ = [%ext "foo" ; "bar"] diff --git a/test/passing/extensions-sugar_always.ml.ref b/test/passing/extensions-sugar_always.ml.ref index 6d880194e4..8ac02cfd88 100644 --- a/test/passing/extensions-sugar_always.ml.ref +++ b/test/passing/extensions-sugar_always.ml.ref @@ -171,3 +171,5 @@ let _ = [%ext let+ a = b in c] + +let _ = "foo" ;%ext "bar" diff --git a/test/passing/extensions.ml b/test/passing/extensions.ml index 749d52eaba..17100038ac 100644 --- a/test/passing/extensions.ml +++ b/test/passing/extensions.ml @@ -186,3 +186,5 @@ let foo = foooooooooooooooooooooooooooo] let _ = [%ext let+ a = b in c] + +let _ = (begin%ext "foo"; "bar" end) diff --git a/test/passing/extensions.ml.ref b/test/passing/extensions.ml.ref index 8d7b7083d5..81453fbd4f 100644 --- a/test/passing/extensions.ml.ref +++ b/test/passing/extensions.ml.ref @@ -177,3 +177,5 @@ let _ = [%ext let+ a = b in c] + +let _ = [%ext "foo" ; "bar"]