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

Make sure the Jane syntax extensions don't depend on our compiler changes #1777

Merged
merged 7 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Explain why we want the buildable-with-upstream restriction
  • Loading branch information
antalsz committed Aug 29, 2023
commit c6d90a937fb7c02b309eb385cb60bbd8bdc4abef
8 changes: 5 additions & 3 deletions ocaml/parsing/jane_syntax.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1168,8 +1168,9 @@ module N_ary_functions = struct
| None -> body
| Some { mode_annotations; type_constraint } ->
let constrained_body =
(* We can't call [Location.ghostify] here, as we need
[jane_syntax.ml] to build with the upstream compilerlibs. *)
(* We can't call [Location.ghostify] here, as we need this file
to build with the upstream compiler; see Note [Buildable with
upstream] in jane_syntax.mli for details. *)
let loc = { body.pexp_loc with loc_ghost = true } in
match type_constraint with
| Pconstraint ty -> Ast_helper.Exp.constraint_ body ty ~loc
Expand Down Expand Up @@ -1310,7 +1311,8 @@ module Layouts = struct

(* Most things here are unprintable because we can't reference any
[Printast] functions that aren't exposed by the upstream compiler, as we
want this file to be compatible with the upstream compiler-libs. *)
want this file to be compatible with the upstream compiler; ; see Note
[Buildable with upstream] in jane_syntax.mli for details. *)
let report_error ~loc = function
| Unexpected_wrapped_type _typ ->
Location.errorf ~loc
Expand Down
18 changes: 18 additions & 0 deletions ocaml/parsing/jane_syntax.mli
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
For details on the rationale behind this approach (and for some of the gory
details), see [Jane_syntax_parsing]. *)

(******************************************************************************)

(* Note [Buildable with upstream]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We want to make sure that the various [Jane_*] modules, along with
[Language_extension_kernel] and a small stub for [Language_extension], are
buildable with the upstream compiler and compiler-libs. This allows us to
import these files into compatibility libraries such as
{{:https://github.com/janestreet/ppxlib_jane}ppxlib_jane}. We have CI tests
which ensure that this property is maintained.

It is possible that at some point we'll really need to depend on new
functionality we provide elsewhere in the compiler; at that point, we can
look into providing stub implementations of these modules for use with the
upstream compiler instead. For now, though, this is sufficient.
*)

(*********************************************)
(* Individual features *)

Expand Down
3 changes: 2 additions & 1 deletion ocaml/parsing/jane_syntax_parsing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ module Make_ast (AST : AST_internal) : AST with type ast = AST.ast = struct
let make_entire_jane_syntax ~loc feature ast =
AST.with_location
(* We can't call [Location.ghostify] here, as we need
[jane_syntax_parsing.ml] to build with the upstream compilerlibs. *)
[jane_syntax_parsing.ml] to build with the upstream compiler; see
Note [Buildable with upstream] in jane_syntax.mli for details. *)
(Ast_helper.with_default_loc { loc with loc_ghost = true } (fun () ->
make_jane_syntax feature [] (ast ())))
loc
Expand Down
Loading