-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add support for new local syntax #73
Conversation
b8c3f29
to
5ecc704
Compare
$ fmt_pattern c lb_pat ) | ||
$ fmt_if_k | ||
(not (List.is_empty lb_args)) | ||
$ wrap_if (has_args && has_modes) "(" ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider refactoring.
match (lb_pat.ast.ppat_desc, lb_exp.ast.pexp_desc) with | ||
(* recognize and undo the pattern of code introduced by | ||
ocaml/ocaml@fd0dc6a0fbf73323c37a73ea7e8ffc150059d6ff to fix | ||
https://caml.inria.fr/mantis/view.php?id=7344 *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This desugaring no longer happens; the constraint is now encoded in pvb_constraint
.
@@ -15,10 +15,8 @@ | |||
|
|||
(* A generic Parsetree mapping class *) | |||
|
|||
(* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning being commented out was the pain source of a bug for a couple hours. I don't wee why it's commented out when there's only like 2 places below that needed to be changed to make the warning pass.
4fae337
to
ccbfecb
Compare
4bbb7ec
to
ae48b5e
Compare
b81a8f3
to
edb9181
Compare
Tested by smashing tree to add mode annotations everywhere possible in jane, and running ocamlformat on entire tree. Obviously could have missed adding annotations in some places, and the annotations are added in a relatively uniform way, but this did successfully reveal a few bugs. |
Currently, CI is failing on some tests unrelated to this change. I'm looking into this, but I don't think it should block review. Update: Resolved. |
7aed70f
to
107d95c
Compare
Consider whether PR 2706 to flambda affects this PR. |
52d931d
to
b20bc81
Compare
It shouldn't. The |
4e8abc5
to
2526cf1
Compare
Signed-off-by: Charlie Gunn <cgunn@janestreet.com> Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Remove code to recognize ast pattern that no longer exists. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modes on arrow types. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Update normalize mapper to prevent bad sugaring. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix ast mapper to not drop modes and modalities in various places. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modes on value bindings. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add support for modes in pattern constraints and expression constraints. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modalities on record declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modalities on value declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix test; in [let (pat @ mode) = exp], the mode is actually attached to the value binding, not the pattern. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests for comments. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix moving comment in record fields. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests and make minor changes for formatting with line breaks. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Test in conjunction with old syntax. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix formatting of tuple patterns where els have modes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add labeled tuple pattern tests. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix labeled tuple pattern punning with modes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix invalid punning of labeled tuple expressions with modes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests for attributes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix issue with comments after [@] and [@@]. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix modes on let-bound tuple patterns. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix parens around aliased patterns with modes Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix tuple patterns with local exprs. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix let class expressions. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Move tests of modes on patterns to failing. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix incorrect dependencies in test causing CI failure. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Rework logic for handling comments after types in label declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Extend tests of label declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests for --break-separators=after. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com>
10ef9f6
to
f396402
Compare
Parse new local syntax, but ignore when formatting. Signed-off-by: Charlie Gunn <cgunn@janestreet.com> Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Remove code to recognize ast pattern that no longer exists. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modes on arrow types. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Update normalize mapper to prevent bad sugaring. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix ast mapper to not drop modes and modalities in various places. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modes on value bindings. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add support for modes in pattern constraints and expression constraints. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modalities on record declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Support modalities on value declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix test; in [let (pat @ mode) = exp], the mode is actually attached to the value binding, not the pattern. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests for comments. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix moving comment in record fields. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests and make minor changes for formatting with line breaks. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Test in conjunction with old syntax. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix formatting of tuple patterns where els have modes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add labeled tuple pattern tests. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix labeled tuple pattern punning with modes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix invalid punning of labeled tuple expressions with modes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests for attributes. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix issue with comments after [@] and [@@]. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix modes on let-bound tuple patterns. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix parens around aliased patterns with modes Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix tuple patterns with local exprs. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix let class expressions. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Move tests of modes on patterns to failing. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Fix incorrect dependencies in test causing CI failure. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Rework logic for handling comments after types in label declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Extend tests of label declarations. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com> Add tests for --break-separators=after. Signed-off-by: Thomas Del Vecchio <tdelvecchio@janestreet.com>
This adds support for modes and modalities in the following positions:
let x @ mode = y
let x : typ @@ mode = y
let _ = (x : typ @@ mode)
type t = typ @ mode -> lbl:typ @ mode -> typ @ mode
type t = { x : typ @@ modality }
type t = A of typ @@ modality * typ @@ modality
val x : typ @@ mode
let ((x @ mode), (y @ mode)) = z
let (f @ mode) (x @ mode) (y @ mode) = z