Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Support local open and let bindings (@SanderSpies) [#2716](https://github.com/reasonml/reason/pull/2716)
- outcome printer: change the printing of `@bs.*` to `@mel.*` (@anmonteiro, [#2755](https://github.com/reasonml/reason/pull/2755))
- Fix outcome printing of optional arguments on OCaml 5.2 (@anmonteiro, [#2753](https://github.com/reasonml/reason/pull/2753))
- support parsing and printing of `external%extension` (@anmonteiro, [#2750](https://github.com/reasonml/reason/pull/2750), [#2766](https://github.com/reasonml/reason/pull/2766))
- support parsing and printing of `external%extension` (@anmonteiro, [#2750](https://github.com/reasonml/reason/pull/2750), [#2766](https://github.com/reasonml/reason/pull/2766), [#2767](https://github.com/reasonml/reason/pull/2767))
- install `refmt` manpage (@anmonteiro, [#2760](https://github.com/reasonml/reason/pull/2760))
- add support for parsing / printing of refutation clause in `switch` (@anmonteiro, [#2765](https://github.com/reasonml/reason/pull/2765))

Expand Down
26 changes: 13 additions & 13 deletions src/reason-parser/reason_pprint_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7174,17 +7174,6 @@ let printer = object(self:'self)
(self#class_self_pattern_and_structure cs)

method signature signatureItems =
let signature_item item =
match item.psig_desc with
| Psig_extension ((extension, PSig [item]), _attrs) ->
begin match item.psig_desc with
(* In case of a value or `external`, the extension gets inlined
`let%private a = 1` *)
| Psig_value ({ pval_prim = [_]; _ } as vd) -> self#primitive_declaration ~extension vd
| _ -> self#signature_item item
end
| _ -> self#signature_item item
in
match signatureItems with
| [] -> atom ""
| first::_ as signatureItems ->
Expand All @@ -7193,7 +7182,7 @@ let printer = object(self:'self)
let loc_end = last.psig_loc.loc_end in
let items =
groupAndPrint
~xf:signature_item
~xf:self#signature_item
~getLoc:(fun x -> x.psig_loc)
~comments:self#comments
signatureItems
Expand All @@ -7207,7 +7196,18 @@ let printer = object(self:'self)
~sep:(SepFinal (";", ";"))
items)

method signature_item x : Layout.t =
method signature_item item : Layout.t =
match item.psig_desc with
| Psig_extension ((extension, PSig [item]), _attrs) ->
begin match item.psig_desc with
(* In case of a value or `external`, the extension gets inlined
`let%private a = 1` *)
| Psig_value ({ pval_prim = [_]; _ } as vd) -> self#primitive_declaration ~extension vd
| _ -> self#signature_item' item
end
| _ -> self#signature_item' item

method signature_item' x : Layout.t =
let item: Layout.t =
match x.psig_desc with
| Psig_type (rf, l) ->
Expand Down
13 changes: 13 additions & 0 deletions test/modules.t/input.re
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,16 @@ let y = Promise.Ops.(
Js.Promise.resolve(x * 2)
)
);

module WithExternalExtension: {
external%foo bar: string => string = "";
[%%foo: external bar: int => int = "hello" ];
} = {
external%foo bar: string => string = "";
[%%foo external bar: int => int = "hello" ];
}

module type TypeWithExternalExtension = {
external%foo bar: string => string = "";
[%%foo: external bar: int => int = "hello" ];
}
13 changes: 13 additions & 0 deletions test/modules.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,17 @@ Format modules
Js.Promise.resolve(x * 2);
)
);

module WithExternalExtension: {
external%foo bar: string => string;
external%foo bar: int => int = "hello";
} = {
external%foo bar: string => string;
external%foo bar: int => int = "hello";
};

module type TypeWithExternalExtension = {
external%foo bar: string => string;
external%foo bar: int => int = "hello";
};
/* From http://stackoverflow.com/questions/1986374/ higher-order-type-constructors-and-functors-in-ocaml */