-
Notifications
You must be signed in to change notification settings - Fork 86
Convert -extension local
to use Jane syntax
#1586
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
Conversation
d6e433e
to
2cdaed5
Compare
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.
I've given it some light review but haven't engaged with the substantial Jane Syntax changes yet.
|
944ca6e
to
c862514
Compare
@ncik-roberts, I think the open conversations and new code need your review now, but I've addressed most of your comments! |
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.
Not completely done yet, but here are some more comments.
My most recent commit reworks the type of |
e98bc19
to
9886a02
Compare
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.
I just pushed a failing test highlighting some issues with how attributes are handled.
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.
A little more review, a few more comments. Just typechecking left, and then this will be fully reviewed.
ocaml/testsuite/tests/jane-modular-syntax/user_error3.compilers.reference
Outdated
Show resolved
Hide resolved
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.
In a conversation with @antalsz, we agreed that this patch would have important effects on ppxs. Merge only with caution. To help us not forget this, I'm putting in a "Request changes". (I'm not sure the exact semantics of this, but I think it shows up in the block that appears above the merge button as a helpful reminder.)
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.
Ok, I think I'm all done with this review attempt. Let me know when you'd like me to take a look after you've had a chance to look at my comments.
@ncik-roberts I made the location saving/restoring automatic, good call |
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.
The changes look good. The remaining things left:
- I have a minor comment for trying to reduce the diff of this last piece.
- Richard left a comment to mark the fact that this may affect ppxes.
- There are a few threads to mark resolved if you agree that they are in fact resolved.
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.
Let's fix the test that's commented out in #1727 — currently, this program's parsetree doesn't round-trip with respect to Pprintast
:
let local_ f x : int -> int = fun y -> x + y in
()
The output is something like:
let local_ f x = ((fun y -> x + y) : (int -> int)) in
()
But the parser treats the type annotation on the LHS of =
specially for let local_ f
: it inserts an Lexp_constrain_local
.
Fixing this bug will allow us to uncomment the test in #1727.
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.
Looks good to me. (Note Richard's unresolved comment — you were going to check that ppxes are ok before we merge this.)
ecba032
to
71d4b5c
Compare
@ncik-roberts: Sorry about the force push; I needed to add some new tests to validate the issue in #1727. Luckily it actually only adds two commits for you to review:
It's worth noting that this uncovers an existing bug in
becomes
I haven't tried to fix that in this PR; unless it's very simple to do, it probably belongs elsewhere. |
Sorry, I should clarify: this does fix the printing issue highlighted in #1727! |
I think these last two commits should be split out into another PR. This PR is already massive, and the last two commits were (a) already issues at the base, and (b) are semantically fairly separate from the reset of the work you did. I think that will make this PR easier to merge and those two commits easier to review in isolation. (But thanks for fixing this problem — pprintast bugs are annoying.) |
Just caught a |
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.
The most recent two commits (ending in "Fix printing of global_
in tupled constructors") look good to me -- I just have a minor comment that you can resolve upon addressing.
836a1ee
to
5738720
Compare
@ncik-roberts: I have split off the two commits you requested and force-pushed. The current range of commits is 85c202c..5738720. I will be squashing and rebasing this PR soon. |
5738720
to
5d807a3
Compare
This is the squashed form of commits 85c202c..5738720, whose individual commit messages are below, followed by rebasing onto `main`. I'm committing the conflicts to hopefully make it possible to review the resolution of the rebase. We'll see how well this works. ---------- Add matches on `Jane_syntax.Core_type.of_ast` Add the `local` extension, but don't use it yet Power `local_` with the modular syntax (but not other modal things) Power `global_` with the modular syntax machinery Update the parser to use Jane syntax for `local_`; buggy w/ `global_` Fix `Local.of_constr_arg`'s attribute handling Update ocamlprof Add constructor argument to `depend.ml` Make `local_` in types contain more attributes This lets us distinguish it from constructor arguments better Correctly update attributes when matching on types/constructor args Bootstrap `make alldepend` Fix printing bug for `local_` Refactor attribute handling This is a big change to `Jane_syntax_parsing` Update passing tests Add `Lexp_constrain_local` Fix `local_` in patterns & the location of `local_` in expressions Delete stray outdated comments Move `exclave_` over to Jane syntax Remove `extension.` options for `[@{non,}tail]` Move curry-tracking over to Jane syntax Reorder attribute addition for comprehensions Rewrite the missed uses of `[%exclave]` to `exclave_` Add some missing documentation Make `Jane_syntax_parsing` no longer depend on `Misc` Bootstrap Update ocamlprof Respond to simple parts of Nick's review Formatting (and content) update for `Jane_syntax` example comments Add test of attributes in `local_ (t[@A])`; currently handled wrong Update: `get_alloc_mode` → `unwrap_mode`, document it, and fix a bug Jane syntax constructor arguments don't come with attributes Add missing invariant documentation Handle locations for `local_` and `exclave_` without using `(); x` Add some missing uses of `Location.ghostify` Rework type of match_jane_syntax_piece Add regression test (currently failing) for attribute handling Respond to small pieces of @ncick-roberts's review Remove `~attr` arguments from individual `Jane_syntax` extensions More reponses to @ncick-roberts's review, including a bug fix Fix `pprintast`'s handling of attributes on `let x = local_ e` Fix bug with parenthesization of `local_` Handle saving/restoring locations with `loc_stack`s Minor review response Remove `Embedded_name.marker_attribute_handler` machinery Tweak `match_jane_syntax` (formerly `match_jane_syntax_piece`) Make `save_location` and `restore_location` automatic Reduce the parser diff Per @riaqn, adjust the type of `check_eq_mode`; also, rename it Added test demonstrating a bug in `Pprintast` Currently, `Pprintast` does not print `global_` on tupled constructor fields correctly, and instead crashes. ``` % cat test.ml; echo; _install/bin/ocamlc -dsource test.ml type t = C of global_ string type t = | C of File "test.ml", line 1, characters 14-21: 1 | type t = C of global_ string ^^^^^^^ Error: Tried to restore a saved location here, but none were found. ``` This is a regression from the previous broken behavior of printing the attribute literally: ``` % cat test.ml; echo; ocamlc -dsource test.ml type t = C of global_ string type t = | C of ((string)[@extension.global ]) ``` The next commit will fix `Pprintast` to have the correct behavior Fix printing of `global_` in tupled constructors Switch from `%(%)` to `%t`
5d807a3
to
8dca801
Compare
In the end, we've decided to go a different direction here, keeping a lighter-weight encoding for local annotations. There is one piece of it all not yet complete, but is tracked by an internal ticket. Closing. |
Naturally, this comes with some Jane syntax changes, designed to make it easier to work with the attribute encoding without having to explicitly think about attributes.
This shouldn't change the user-facing syntax at all, but it removes the ability to explicitly write attributes (e.g.,
[@local]
) or extension nodes (e.g.,[%exclave]
). Some things are left as attributes:[@tail]
and[@nontail]
, because they really do want to be explicit modifiers on terms; and[@curry]
in terms, although see below. The implicit[@curry]
in types is left alone as an attribute, but its name is changed.There is one outstanding question: I left the handling of
[@curry]
onfun
terms alone, as an explicit attribute, but I wasn't sure if that was correct.We leave
%extension.escape
alone because @ncik-roberts's forthcoming syntactic function arity parsing PR should eliminate it.Reviewer: @ncik-roberts, I think!
EDIT:
unboxed-primitive-args/test.ml
is failing locally because it can't findcaml/mlvalues.h
; I haven't tried to debug this yet, but I can't see how it's related to these changes.