From 6e7233f27d5ec214b8711849cb1d85430a3c312c Mon Sep 17 00:00:00 2001 From: a-c-sreedhar-reddy Date: Thu, 30 Dec 2021 10:11:23 +0530 Subject: [PATCH] fix: prevent stripping of quotes for empty polymorphic variant --- src/res_printer.ml | 8 +++++++- tests/printer/pattern/expected/variant.res.txt | 2 ++ tests/printer/pattern/variant.res | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/res_printer.ml b/src/res_printer.ml index 42d2de77..a58ed5e7 100644 --- a/src/res_printer.ml +++ b/src/res_printer.ml @@ -459,7 +459,13 @@ let printPolyVarIdent txt = Doc.text txt; Doc.text"\"" ] - | NormalIdent -> Doc.text txt + | NormalIdent -> match txt with + | "" -> Doc.concat [ + Doc.text "\""; + Doc.text txt; + Doc.text"\"" + ] + | _ -> Doc.text txt let printLident l = match l with diff --git a/tests/printer/pattern/expected/variant.res.txt b/tests/printer/pattern/expected/variant.res.txt index d37f2929..74d2f187 100644 --- a/tests/printer/pattern/expected/variant.res.txt +++ b/tests/printer/pattern/expected/variant.res.txt @@ -43,3 +43,5 @@ switch numericPolyVar { | #42 => () | #3(x, y, z) => Js.log3(x, y, z) } + +let e = #"" diff --git a/tests/printer/pattern/variant.res b/tests/printer/pattern/variant.res index 240d5146..dce2b21a 100644 --- a/tests/printer/pattern/variant.res +++ b/tests/printer/pattern/variant.res @@ -43,3 +43,5 @@ switch numericPolyVar { | #42 => () | #3(x, y, z) => Js.log3(x, y, z) } + +let e = #"" \ No newline at end of file