Skip to content

Commit

Permalink
Fix an issue with nested parentheses in type patterns (#634)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alasdair authored Jul 20, 2024
1 parent 9a7b1e0 commit 561df10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/initial_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/typecheck/pass/type_pat_parens.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
default Order dec

$include <prelude.sail>

val main : unit -> unit

function main() = {
let _ as bool((((('b))))) = true;
}

0 comments on commit 561df10

Please sign in to comment.