Skip to content

Commit

Permalink
Add (type _) as an allowed pattern
Browse files Browse the repository at this point in the history
Previously a hole, `_`, was not allowed in place of the name of a `(type x)`
pattern.
  • Loading branch information
polytypic committed Feb 23, 2020
1 parent 7af6568 commit 1e8299d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 3 additions & 4 deletions parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,15 @@ bind :

atpat :
| head
{ if $1.it = "_" then holeP@@at() else varP($1)@@at() }
{ headP $1 }
| LBRACE decon RBRACE
{ strP($2)@@at() }
| LPAR RPAR
{ strP([])@@at() }
| LPAR patlist RPAR
{ match $2 with [p] -> p | ps -> tupP(ps)@@at() }
| LPAR TYPE name typparamlist RPAR
{ annotP(varP($3.it@@ati 3)@@ati 3,
funT($4, TypT@@ati 2, Pure@@ati 2)@@at())@@at() }
| LPAR TYPE head typparamlist RPAR
{ annotP(headP $3, funT($4, TypT@@ati 2, Pure@@ati 2)@@at())@@at() }
;
apppat :
| atpat
Expand Down
4 changes: 4 additions & 0 deletions regression.1ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Equivalence: {

;;

hole_is_allowed_type_pattern (type _ _) = ();

;;

type_error { type_error 101 };

;;
Expand Down
3 changes: 3 additions & 0 deletions syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ let varP(x) = VarB(x, VarE("$"@@x.at)@@x.at)@@x.at, None
let holeP : bind * typ option =
EmptyB@@nowhere_region, None

let headP id =
if id.it = "_" then holeP@@id.at else varP(id)@@id.at

let asTopt(to1, to2) =
match to1, to2 with
| None, None -> None
Expand Down

0 comments on commit 1e8299d

Please sign in to comment.