diff --git a/CHANGELOG.md b/CHANGELOG.md index f238068159..71c7d3be11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ # 10.1.0-rc.3 +#### :bug: Bug Fix + +- Fix issue where exhaustiveness check for pattern matching char was not working https://github.com/rescript-lang/rescript-compiler/issues/5557 + # 10.1.0-rc.2 #### :bug: Bug Fix diff --git a/jscomp/ml/typecore.ml b/jscomp/ml/typecore.ml index 012cdd765c..4dbc11b7c7 100644 --- a/jscomp/ml/typecore.ml +++ b/jscomp/ml/typecore.ml @@ -1350,6 +1350,11 @@ let partial_pred ~lev ?mode ?explode env expected_ty constrs labels p = let state = save_state env in try reset_pattern None true; + let expected_ty = match p.ppat_desc, expected_ty.desc with + | Ppat_constant (Pconst_integer _ ), Tconstr (path, [], _) when Path.same path Predef.path_char -> + (* Constants such as 'x' are represented as Pconst_integer but expected to have type char *) + Predef.type_int + | _ -> expected_ty in let typed_p = Ctype.with_passive_variants (type_pat ~allow_existentials:true ~lev diff --git a/lib/4.06.1/unstable/js_compiler.ml b/lib/4.06.1/unstable/js_compiler.ml index 0e6879f617..d4dca29dfe 100644 --- a/lib/4.06.1/unstable/js_compiler.ml +++ b/lib/4.06.1/unstable/js_compiler.ml @@ -40301,6 +40301,11 @@ let partial_pred ~lev ?mode ?explode env expected_ty constrs labels p = let state = save_state env in try reset_pattern None true; + let expected_ty = match p.ppat_desc, expected_ty.desc with + | Ppat_constant (Pconst_integer _ ), Tconstr (path, [], _) when Path.same path Predef.path_char -> + (* Constants such as 'x' are represented as Pconst_integer but expected to have type char *) + Predef.type_int + | _ -> expected_ty in let typed_p = Ctype.with_passive_variants (type_pat ~allow_existentials:true ~lev diff --git a/lib/4.06.1/unstable/js_playground_compiler.ml b/lib/4.06.1/unstable/js_playground_compiler.ml index 314e28560a..22e7d91b52 100644 --- a/lib/4.06.1/unstable/js_playground_compiler.ml +++ b/lib/4.06.1/unstable/js_playground_compiler.ml @@ -40301,6 +40301,11 @@ let partial_pred ~lev ?mode ?explode env expected_ty constrs labels p = let state = save_state env in try reset_pattern None true; + let expected_ty = match p.ppat_desc, expected_ty.desc with + | Ppat_constant (Pconst_integer _ ), Tconstr (path, [], _) when Path.same path Predef.path_char -> + (* Constants such as 'x' are represented as Pconst_integer but expected to have type char *) + Predef.type_int + | _ -> expected_ty in let typed_p = Ctype.with_passive_variants (type_pat ~allow_existentials:true ~lev diff --git a/lib/4.06.1/whole_compiler.ml b/lib/4.06.1/whole_compiler.ml index 396eb85143..0ec973290c 100644 --- a/lib/4.06.1/whole_compiler.ml +++ b/lib/4.06.1/whole_compiler.ml @@ -216688,6 +216688,11 @@ let partial_pred ~lev ?mode ?explode env expected_ty constrs labels p = let state = save_state env in try reset_pattern None true; + let expected_ty = match p.ppat_desc, expected_ty.desc with + | Ppat_constant (Pconst_integer _ ), Tconstr (path, [], _) when Path.same path Predef.path_char -> + (* Constants such as 'x' are represented as Pconst_integer but expected to have type char *) + Predef.type_int + | _ -> expected_ty in let typed_p = Ctype.with_passive_variants (type_pat ~allow_existentials:true ~lev