From 561df105058bd9c2bbcdc15d7dc50512bf8dfb64 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Sat, 20 Jul 2024 03:58:37 +0100 Subject: [PATCH] Fix an issue with nested parentheses in type patterns (#634) Something like bool(((('b)))) wouldn't work, and even though it's unlikely anyone would want to write this, there's no particular reason it should fail. --- src/lib/initial_check.ml | 1 + test/typecheck/pass/type_pat_parens.sail | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 test/typecheck/pass/type_pat_parens.sail diff --git a/src/lib/initial_check.ml b/src/lib/initial_check.ml index 055b94598..14dd536d7 100644 --- a/src/lib/initial_check.ml +++ b/src/lib/initial_check.ml @@ -545,6 +545,7 @@ let rec to_ast_typ_pat ctx (P.ATyp_aux (aux, l)) = | P.ATyp_app (P.Id_aux (P.Id "bool", il), typs) -> TP_aux (TP_app (Id_aux (Id "atom_bool", il), List.map (to_ast_typ_pat ctx) typs), l) | P.ATyp_app (f, typs) -> TP_aux (TP_app (to_ast_id ctx f, List.map (to_ast_typ_pat ctx) typs), l) + | P.ATyp_parens atyp -> to_ast_typ_pat ctx atyp | _ -> raise (Reporting.err_typ l "Unexpected type in type pattern") let is_wild_fpat = function P.FP_aux (P.FP_wild, _) -> true | _ -> false diff --git a/test/typecheck/pass/type_pat_parens.sail b/test/typecheck/pass/type_pat_parens.sail new file mode 100644 index 000000000..5b2f431ae --- /dev/null +++ b/test/typecheck/pass/type_pat_parens.sail @@ -0,0 +1,9 @@ +default Order dec + +$include + +val main : unit -> unit + +function main() = { + let _ as bool((((('b))))) = true; +}