Skip to content

Remove Jane Syntax for n-ary functions#2780

Merged
ncik-roberts merged 7 commits intomainfrom
nroberts-remove-jane-syntax-for-n-ary-functions
Jul 29, 2024
Merged

Remove Jane Syntax for n-ary functions#2780
ncik-roberts merged 7 commits intomainfrom
nroberts-remove-jane-syntax-for-n-ary-functions

Conversation

@ncik-roberts
Copy link
Copy Markdown
Contributor

Start using a direct encoding of n-ary functions in the parsetree. Delete the Jane Syntax encoding for n-ary functions.

We've changed the function AST beyond the making it n-ary. We also track mode and jkind annotations. So, this PR is not a straightforward backport; we need to tack on our extensions to the code from upstream.

There are a few broad classes of diff in this feature:

  • Straightforward backport. Example: ast_helper.ml, ast_invariants.ml. Here, we just take the code from upstream.
  • Half-backport, half–adding our extensions. Example: printast.ml. Here, we can mostly take the code from upstream. In some cases, I move some code around in a file (e.g. ast_mapper.ml) to get it to match more closely where it lives upstream and thus to reduce drift.
  • Removal of coercion expr : Mode_expr.Const.t :> _ Location.loc (and same for jkinds). That's because the parsetree type is no longer private (the parsetree is an mli-only file). I could have minted a new file to keep these types private, but I judged it to not be worth the trouble. The private-ness here was just about making it less likely to mix up strings — it doesn't guard any invariants.
  • Small changes to the locations in tests. Example: ocaml/testsuite/tests/typing-gadts/pr7269.ml (this one matches upstream). Another example: ocaml/testsuite/tests/parsetree/modes_ast_mapper.reference (this one is just fine; we've changed the location of the mode annotation in a way that seems more accurate anyway).

When I say that a code is a "backport", I encourage you to compare against the code in https://github.com/ocaml/ocaml.

Please let @ncik-roberts merge this! This implies some work in ppxes, and I'd like to be sure we're in a good spot to do that work before committing ourselves to doing it.

Reviewer: We're discussing internally.

@ncik-roberts
Copy link
Copy Markdown
Contributor Author

I've deleted the "build Jane Syntax with upstream" CI check — I added this originally for a reason that no longer applies, now that we're modifying the parsetree.

@ncik-roberts ncik-roberts force-pushed the nroberts-remove-jane-syntax-for-n-ary-functions branch from 17d6f1a to 63126cf Compare July 15, 2024 18:59
@ncik-roberts ncik-roberts mentioned this pull request Jul 17, 2024
@ncik-roberts
Copy link
Copy Markdown
Contributor Author

@freemagma The last commit probably should be reviewed (I noticed the issue in testing)

@ncik-roberts ncik-roberts merged commit f4911e0 into main Jul 29, 2024
@ncik-roberts ncik-roberts deleted the nroberts-remove-jane-syntax-for-n-ary-functions branch July 29, 2024 15:13
@freemagma freemagma restored the nroberts-remove-jane-syntax-for-n-ary-functions branch July 29, 2024 18:45
lukemaurer pushed a commit that referenced this pull request Oct 23, 2024
* Remove Jane Syntax for n-ary functions

* Delete now-unnecessary coercions

* Remove unintentional space

* Add unintentionally dropped comment

* Remove no-longer-useful Jane Syntax check

* Rework pprintast to differentiate pexp_newtype from pexp_function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport from upstream OCaml lexer/parser Changes to the lexer and parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants