Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to name existentials in pattern-matching #9584

Merged
merged 24 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ typing/ctype.cmi : \
typing/type_immediacy.cmi \
typing/path.cmi \
parsing/longident.cmi \
parsing/location.cmi \
typing/ident.cmi \
typing/env.cmi \
parsing/asttypes.cmi
Expand Down
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ Working version

### Type system:

- #9584, #7074: Allow to name existentials in pattern-matching
One can now write '(Cstr (type a) (x, y : int * a))' to give a name to
existentials freshly introduced by GADT constructors.
(Jacques Garrigue, review by Leo White and Gabriel Scherer)

- #10174: Make Tsubst more robust by avoiding strange workarounds
(Takafumi Saikawa and Jacques Garrigue, review by Gabriel Scherer and
Florian Angeletti)
Expand Down
4,403 changes: 2,248 additions & 2,155 deletions boot/menhir/parser.ml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lambda/matching.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1746,12 +1746,12 @@ let divide_constant ctx m =
(* Matching against a constructor *)

let get_key_constr = function
| { pat_desc = Tpat_construct (_, cstr, _) } -> cstr
| { pat_desc = Tpat_construct (_, cstr, _, _) } -> cstr
| _ -> assert false

let get_pat_args_constr p rem =
match p with
| { pat_desc = Tpat_construct (_, _, args) } -> args @ rem
| { pat_desc = Tpat_construct (_, _, args, _) } -> args @ rem
| _ -> assert false

let get_expr_args_constr ~scopes head (arg, _mut) rem =
Expand Down