diff --git a/compiler/src/typed/parmatch.re b/compiler/src/typed/parmatch.re index 688e49fb6..121fbeede 100644 --- a/compiler/src/typed/parmatch.re +++ b/compiler/src/typed/parmatch.re @@ -2099,7 +2099,8 @@ let untype_constant = Parsetree.PConstBytes(Location.mknoloc(Bytes.to_string(b))) | Const_string(s) => Parsetree.PConstString(Location.mknoloc(Printf.sprintf("\"%s\"", s))) - | Const_char(c) => Parsetree.PConstChar(Location.mknoloc(c)) + | Const_char(c) => + Parsetree.PConstChar(Location.mknoloc(Printf.sprintf("\'%s\'", c))) | Const_bool(b) => Parsetree.PConstBool(b) | Const_void => Parsetree.PConstVoid; diff --git a/compiler/src/typed/printpat.re b/compiler/src/typed/printpat.re index 451858ca3..66e09e4bf 100644 --- a/compiler/src/typed/printpat.re +++ b/compiler/src/typed/printpat.re @@ -34,7 +34,7 @@ let pretty_const = c => | Const_number(Const_number_bigint({bigint_rep})) => bigint_rep | Const_bytes(b) => Printf.sprintf("%S", Bytes.to_string(b)) | Const_string(s) => Printf.sprintf("%S", s) - | Const_char(c) => Printf.sprintf("%S", c) + | Const_char(c) => Printf.sprintf("\'%s\'", c) | Const_float64(f) | Const_float32(f) => Printf.sprintf("%f", f) | Const_int8(i) => Printf.sprintf("%lds", i) diff --git a/compiler/test/suites/pattern_matching.re b/compiler/test/suites/pattern_matching.re index 23778e90f..60d27ae4f 100644 --- a/compiler/test/suites/pattern_matching.re +++ b/compiler/test/suites/pattern_matching.re @@ -236,6 +236,13 @@ describe("pattern matching", ({test, testSkip}) => { "constant_match_4", "match ((\"foo\", 5)) { (\"foo\", n) when n == 7 => false, (\"foo\", 9) when true => false, (\"foo\", n) when n == 5 => true, _ => false }", ); + assertWarning( + "nested_constant_match_1", + "match ([> 'a']) { + [> 'l', 'e'] => void, + }", + Warnings.PartialMatch("([> 'l', _]|[> _, _]|[> ])"), + ); // Constant low level wasm type patterns assertSnapshot( "low_level_constant_match_1",