Skip to content

Commit 2e8d490

Browse files
committed
Treat @meth annotation as making the type uncurried.
This restores examples in the documentation that have been broken: ```res type person = {@meth "say": (string, string) => unit} @Val external john: person = "john" john["say"]("hey", "jude") ``` Since there's no way in the `.res` syntax to call methods, the `@meth` annotation simply makes the type uncurried.
1 parent 85c2dce commit 2e8d490

9 files changed

+39
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ These are only breaking changes for unformatted code.
5151
- Remove processing of objects expressions, which don't exist in `.res` syntax (`Pexp_object`) https://github.com/rescript-lang/rescript-compiler/pull/5841
5252
- Remove class type processing from compiler ppx https://github.com/rescript-lang/rescript-compiler/pull/5842
5353
- Remove method application via operator `##`, which does not exist in `.res` syntax https://github.com/rescript-lang/rescript-compiler/pull/5844
54+
- Treat `@meth` annotation as making the type uncurried for backwards compatibitly with some examples https://github.com/rescript-lang/rescript-compiler/pull/5845
5455

5556
# 10.1.0-rc.6
5657

jscomp/frontend/ast_core_type_class_type.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ let typ_mapper (self : Bs_ast_mapper.mapper) (ty : Parsetree.core_type) =
8383
| Uncurry _ -> Ast_typ_uncurry.to_uncurry_type loc self label args body
8484
| Meth_callback _ ->
8585
Ast_typ_uncurry.to_method_callback_type loc self label args body
86-
| Method _ -> Ast_typ_uncurry.to_method_type loc self label args body
86+
| Method _ ->
87+
(* Treat @meth as making the type uncurried, for backwards compatibility *)
88+
Ast_typ_uncurry.to_uncurry_type loc self label args body
8789
| Nothing -> Bs_ast_mapper.default_mapper.typ self ty)
8890
| { ptyp_desc = Ptyp_object (methods, closed_flag); ptyp_loc = loc } ->
8991
let ( +> ) attr (typ : Parsetree.core_type) =

jscomp/main/builtin_cmi_datasets.ml

+3-3
Large diffs are not rendered by default.

jscomp/test/build.ninja

+2-1
Large diffs are not rendered by default.

jscomp/test/meth_annotation.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
4+
john.say("hey", "jude");
5+
6+
/* Not a pure module */

jscomp/test/meth_annotation.res

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// The @meth annotation is for backwards compatibility. It just makes the type uncurried.
2+
type person = {@meth "say": (string, string) => unit}
3+
4+
@val external john: person = "john"
5+
6+
john["say"]("hey", "jude")

lib/4.06.1/unstable/js_compiler.ml

+6-4
Large diffs are not rendered by default.

lib/4.06.1/unstable/js_playground_compiler.ml

+6-4
Large diffs are not rendered by default.

lib/4.06.1/whole_compiler.ml

+6-4
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)