Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/typed/parmatch.re
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/typed/printpat.re
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions compiler/test/suites/pattern_matching.re
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down