Skip to content

Commit daea31f

Browse files
committed
Merge branch 'master' into result-get-or-throw-message
2 parents e5ea16c + 5109bb0 commit daea31f

File tree

77 files changed

+960
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+960
-416
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
- name: Run rewatch unit tests
135135
if: steps.rewatch-build-cache.outputs.cache-hit != 'true'
136136
run: |
137-
cargo test --manifest-path rewatch/Cargo.toml
137+
cargo test --manifest-path rewatch/Cargo.toml --release
138138

139139
- name: Copy rewatch binary
140140
run: |
@@ -360,6 +360,14 @@ jobs:
360360
if: runner.os != 'Windows'
361361
run: make -C tests/gentype_tests/typescript-react-example clean test
362362

363+
# On Windows, after running setup-ocaml (if it wasn't cached yet or the cache couldn't be restored),
364+
# Cygwin bash is used instead of Git Bash for Windows, breaking the rewatch tests.
365+
# So we need to adjust the path to bring back Git Bash for Windows.
366+
- name: Rewatch tests need Git Bash for Windows
367+
if: ${{ runner.os == 'Windows' }}
368+
run: echo "C:\Program Files\Git\bin" >> $GITHUB_PATH
369+
shell: bash
370+
363371
- name: Run rewatch tests
364372
run: ./rewatch/tests/suite-ci.sh
365373
shell: bash

CHANGELOG.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,55 @@
1010
> - :nail_care: [Polish]
1111
> - :house: [Internal]
1212

13-
# 12.0.0-beta.2 (Unreleased)
13+
# 12.0.0-beta.3 (Unreleased)
1414

1515
#### :boom: Breaking Change
1616

1717
- `Result.getOrThrow` now throws a JS error instead of a `Not_found` ReScript exception. https://github.com/rescript-lang/rescript/pull/7630
18-
- Rust implementation of the `rescript format` command. Command line options changed from `-all`, `-check` and `-stdin` to `--all`, `--check` and `--stdin` compared to the legacy implementation. https://github.com/rescript-lang/rescript/pull/7603
18+
19+
#### :rocket: New Feature
20+
21+
- Add optional `message` argument to `Result.getOrThrow` and improve default error message. https://github.com/rescript-lang/rescript/pull/7630
1922

2023
#### :nail_care: Polish
2124

22-
- Add missing backtick and spaces to `Belt.Map.map` doc comment. https://github.com/rescript-lang/rescript/pull/7632
25+
- Configuration fields `bs-dependencies`, `bs-dev-dependencies` and `bsc-flags` are now deprecated in favor of `dependencies`, `dev-dependencies` and `compiler-flags`. https://github.com/rescript-lang/rescript/pull/7658
2326

24-
#### :house: Internal
27+
# 12.0.0-beta.2
2528

26-
- Remove internal/unused `-bs-v` flag. https://github.com/rescript-lang/rescript/pull/7627
27-
- Remove unused `-bs-D` and `-bs-list-conditionals` flags. https://github.com/rescript-lang/rescript/pull/7631
28-
- Remove obsolete jsx options. https://github.com/rescript-lang/rescript/pull/7633
29-
- Remove obsolete option `-bs-unsafe-empty-array`. https://github.com/rescript-lang/rescript/pull/7635
30-
- Clean up `config.ml`. https://github.com/rescript-lang/rescript/pull/7636
31-
- Rewatch: simplify getting bsc path. https://github.com/rescript-lang/rescript/pull/7634
32-
- Rewatch: only get `"type": "dev"` source files for local packages. https://github.com/rescript-lang/rescript/pull/7646
33-
- Rewatch: add support for `rescript -w` for compatibility. https://github.com/rescript-lang/rescript/pull/7649
29+
#### :boom: Breaking Change
30+
31+
- Rust implementation of the `rescript format` command. Command line options changed from `-all`, `-check` and `-stdin` to `--all`, `--check` and `--stdin` compared to the legacy implementation. https://github.com/rescript-lang/rescript/pull/7603
3432

3533
#### :rocket: New Feature
3634

3735
- Add experimental command to `rescript-tools` for extracting all ReScript code blocks from markdown, either a md-file directly, or inside of docstrings in ReScript code. https://github.com/rescript-lang/rescript/pull/7623
38-
- Add optional `message` argument to `Result.getOrThrow` and improve default error message. https://github.com/rescript-lang/rescript/pull/7630
3936

4037
#### :bug: Bug fix
4138

4239
- Fix `typeof` parens on functions. https://github.com/rescript-lang/rescript/pull/7643
43-
- Rewatch: Add --dev flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
40+
- Rewatch: Add `--dev` flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
4441
- Rewatch: Use root package suffix in clean log messages. https://github.com/rescript-lang/rescript/pull/7648
4542
- Fix inside comment printing for empty dict. https://github.com/rescript-lang/rescript/pull/7654
4643
- Fix I/O error message when trying to extract extra info from non-existing file. https://github.com/rescript-lang/rescript/pull/7656
44+
- Fix fatal error when JSX expression used without configuring JSX in `rescript.json`. https://github.com/rescript-lang/rescript/pull/7656
45+
- Rewatch: Only allow access to `"bs-dev-dependencies"` from `"type": "dev"` source files. https://github.com/rescript-lang/rescript/pull/7650
46+
47+
#### :nail_care: Polish
48+
49+
- Add missing backtick and spaces to `Belt.Map.map` doc comment. https://github.com/rescript-lang/rescript/pull/7632
50+
- AST: store the attributes directly on function arguments. https://github.com/rescript-lang/rescript/pull/7660
51+
52+
#### :house: Internal
53+
54+
- Remove internal/unused `-bs-v` flag. https://github.com/rescript-lang/rescript/pull/7627
55+
- Remove unused `-bs-D` and `-bs-list-conditionals` flags. https://github.com/rescript-lang/rescript/pull/7631
56+
- Remove obsolete jsx options. https://github.com/rescript-lang/rescript/pull/7633
57+
- Remove obsolete option `-bs-unsafe-empty-array`. https://github.com/rescript-lang/rescript/pull/7635
58+
- Clean up `config.ml`. https://github.com/rescript-lang/rescript/pull/7636
59+
- Rewatch: simplify getting bsc path. https://github.com/rescript-lang/rescript/pull/7634
60+
- Rewatch: only get `"type": "dev"` source files for local packages. https://github.com/rescript-lang/rescript/pull/7646
61+
- Rewatch: add support for `rescript -w` for compatibility. https://github.com/rescript-lang/rescript/pull/7649
4762

4863
# 12.0.0-beta.1
4964

compiler/common/bs_version.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
* You should have received a copy of the GNU Lesser General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24-
let version = "12.0.0-beta.2"
24+
let version = "12.0.0-beta.3"
2525
let header = "// Generated by ReScript, PLEASE EDIT WITH CARE"
2626
let package_name = ref "rescript"

compiler/frontend/ast_core_type.ml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ let from_labels ~loc arity labels : t =
9595
in
9696
let args =
9797
Ext_list.map2 labels tyvars (fun label tyvar ->
98-
{Parsetree.lbl = Asttypes.Labelled label; typ = tyvar})
98+
{Parsetree.attrs = []; lbl = Asttypes.Labelled label; typ = tyvar})
9999
in
100100
Typ.arrows ~loc args result_type
101101

@@ -131,39 +131,22 @@ let get_curry_arity (ty : t) =
131131

132132
let is_arity_one ty = get_curry_arity ty = 1
133133

134-
type param_type = {
135-
label: Asttypes.arg_label;
136-
ty: Parsetree.core_type;
137-
attr: Parsetree.attributes;
138-
loc: loc;
139-
}
140-
141-
let mk_fn_type (new_arg_types_ty : param_type list) (result : t) : t =
134+
let mk_fn_type ~loc (new_arg_types_ty : Parsetree.arg list) (result : t) : t =
142135
let t =
143-
Ext_list.fold_right new_arg_types_ty result
144-
(fun {label; ty; attr; loc} acc ->
145-
Ast_helper.Typ.arrow ~loc ~attrs:attr ~arity:None
146-
{lbl = label; typ = ty} acc)
136+
Ext_list.fold_right new_arg_types_ty result (fun {lbl; typ; attrs} acc ->
137+
Ast_helper.Typ.arrow ~loc ~attrs ~arity:None {attrs = []; lbl; typ} acc)
147138
in
148139
match t.ptyp_desc with
149140
| Ptyp_arrow arr ->
150141
let arity = List.length new_arg_types_ty in
151142
{t with ptyp_desc = Ptyp_arrow {arr with arity = Some arity}}
152143
| _ -> t
153144

154-
let list_of_arrow (ty : t) : t * param_type list =
145+
let list_of_arrow (ty : t) : t * Parsetree.arg list =
155146
let rec aux (ty : t) acc =
156147
match ty.ptyp_desc with
157148
| Ptyp_arrow {arg; ret; arity} when arity = None || acc = [] ->
158-
aux ret
159-
(({
160-
label = arg.lbl;
161-
ty = arg.typ;
162-
attr = ty.ptyp_attributes;
163-
loc = ty.ptyp_loc;
164-
}
165-
: param_type)
166-
:: acc)
149+
aux ret (arg :: acc)
167150
| Ptyp_poly (_, ty) ->
168151
(* should not happen? *)
169152
Bs_syntaxerr.err ty.ptyp_loc Unhandled_poly_type
@@ -173,6 +156,6 @@ let list_of_arrow (ty : t) : t * param_type list =
173156

174157
let add_last_obj (ty : t) (obj : t) =
175158
let result, params = list_of_arrow ty in
176-
mk_fn_type
177-
(params @ [{label = Nolabel; ty = obj; attr = []; loc = obj.ptyp_loc}])
159+
mk_fn_type ~loc:obj.ptyp_loc
160+
(params @ [{lbl = Nolabel; typ = obj; attrs = []}])
178161
result

compiler/frontend/ast_core_type.mli

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,9 @@ val get_uncurry_arity : t -> int option
4747
None -- means not a function
4848
*)
4949

50-
type param_type = {
51-
label: Asttypes.arg_label;
52-
ty: t;
53-
attr: Parsetree.attributes;
54-
loc: Location.t;
55-
}
50+
val mk_fn_type : loc:Location.t -> Parsetree.arg list -> t -> t
5651

57-
val mk_fn_type : param_type list -> t -> t
58-
59-
val list_of_arrow : t -> t * param_type list
52+
val list_of_arrow : t -> t * Parsetree.arg list
6053
(** fails when Ptyp_poly *)
6154

6255
val add_last_obj : t -> t -> t

compiler/frontend/ast_derive_abstract.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ let handle_tdcl light (tdcl : Parsetree.type_declaration) :
8484
( [],
8585
(if has_optional_field then
8686
Ast_helper.Typ.arrow ~loc ~arity:None
87-
{lbl = Nolabel; typ = Ast_literal.type_unit ()}
87+
{attrs = []; lbl = Nolabel; typ = Ast_literal.type_unit ()}
8888
core_type
8989
else core_type),
9090
[] )
@@ -116,19 +116,19 @@ let handle_tdcl light (tdcl : Parsetree.type_declaration) :
116116
if is_optional then
117117
let optional_type = Ast_core_type.lift_option_type pld_type in
118118
( Ast_helper.Typ.arrow ~loc:pld_loc ~arity
119-
{lbl = Asttypes.Optional pld_name; typ = pld_type}
119+
{attrs = []; lbl = Asttypes.Optional pld_name; typ = pld_type}
120120
maker,
121121
Val.mk ~loc:pld_loc
122122
(if light then pld_name
123123
else {pld_name with txt = pld_name.txt ^ "Get"})
124124
~attrs:get_optional_attrs ~prim
125125
(Ast_helper.Typ.arrow ~loc ~arity:(Some 1)
126-
{lbl = Nolabel; typ = core_type}
126+
{attrs = []; lbl = Nolabel; typ = core_type}
127127
optional_type)
128128
:: acc )
129129
else
130130
( Ast_helper.Typ.arrow ~loc:pld_loc ~arity
131-
{lbl = Asttypes.Labelled pld_name; typ = pld_type}
131+
{attrs = []; lbl = Asttypes.Labelled pld_name; typ = pld_type}
132132
maker,
133133
Val.mk ~loc:pld_loc
134134
(if light then pld_name
@@ -140,7 +140,7 @@ let handle_tdcl light (tdcl : Parsetree.type_declaration) :
140140
[External_arg_spec.dummy] Return_identity
141141
(Js_get {js_get_name = prim_as_name; js_get_scopes = []}))
142142
(Ast_helper.Typ.arrow ~loc ~arity:(Some 1)
143-
{lbl = Nolabel; typ = core_type}
143+
{attrs = []; lbl = Nolabel; typ = core_type}
144144
pld_type)
145145
:: acc )
146146
in
@@ -149,9 +149,9 @@ let handle_tdcl light (tdcl : Parsetree.type_declaration) :
149149
if is_current_field_mutable then
150150
let setter_type =
151151
Ast_helper.Typ.arrow ~arity:(Some 2)
152-
{lbl = Nolabel; typ = core_type}
152+
{attrs = []; lbl = Nolabel; typ = core_type}
153153
(Ast_helper.Typ.arrow ~arity:None
154-
{lbl = Nolabel; typ = pld_type} (* setter *)
154+
{attrs = []; lbl = Nolabel; typ = pld_type} (* setter *)
155155
(Ast_literal.type_unit ()))
156156
in
157157
Val.mk ~loc:pld_loc

compiler/frontend/ast_derive_js_mapper.ml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ let erase_type_str =
6969
Str.primitive
7070
(Val.mk ~prim:["%identity"]
7171
{loc = noloc; txt = erase_type_lit}
72-
(Ast_helper.Typ.arrow ~arity:(Some 1) {lbl = Nolabel; typ = any} any))
72+
(Ast_helper.Typ.arrow ~arity:(Some 1)
73+
{attrs = []; lbl = Nolabel; typ = any}
74+
any))
7375

7476
let unsafe_index = "_index"
7577

@@ -79,8 +81,11 @@ let unsafe_index_get =
7981
(Val.mk ~prim:[""]
8082
{loc = noloc; txt = unsafe_index}
8183
~attrs:[Ast_attributes.get_index]
82-
(Ast_helper.Typ.arrow ~arity:None {lbl = Nolabel; typ = any}
83-
(Ast_helper.Typ.arrow ~arity:None {lbl = Nolabel; typ = any} any)))
84+
(Ast_helper.Typ.arrow ~arity:None
85+
{attrs = []; lbl = Nolabel; typ = any}
86+
(Ast_helper.Typ.arrow ~arity:None
87+
{attrs = []; lbl = Nolabel; typ = any}
88+
any)))
8489

8590
let unsafe_index_get_exp = Exp.ident {loc = noloc; txt = Lident unsafe_index}
8691

@@ -132,7 +137,7 @@ let app1 = Ast_compatible.app1
132137
let app2 = Ast_compatible.app2
133138

134139
let ( ->~ ) a b =
135-
Ast_helper.Typ.arrow ~arity:(Some 1) {lbl = Nolabel; typ = a} b
140+
Ast_helper.Typ.arrow ~arity:(Some 1) {attrs = []; lbl = Nolabel; typ = a} b
136141

137142
let raise_when_not_found_ident =
138143
Longident.Ldot (Lident Primitive_modules.util, "raiseWhenNotFound")
@@ -305,7 +310,7 @@ let init () =
305310
let to_js_type result =
306311
Ast_comb.single_non_rec_val pat_to_js
307312
(Ast_helper.Typ.arrow ~arity:(Some 1)
308-
{lbl = Nolabel; typ = core_type}
313+
{attrs = []; lbl = Nolabel; typ = core_type}
309314
result)
310315
in
311316
let new_type, new_tdcl =

compiler/frontend/ast_derive_projector.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ let init () =
137137
Ext_list.map label_declarations (fun {pld_name; pld_type} ->
138138
Ast_comb.single_non_rec_val ?attrs:gentype_attrs pld_name
139139
(Ast_helper.Typ.arrow ~arity:(Some 1)
140-
{lbl = Nolabel; typ = core_type}
140+
{attrs = []; lbl = Nolabel; typ = core_type}
141141
pld_type
142142
(*arity will alwys be 1 since these are single param functions*)))
143143
| Ptype_variant constructor_declarations ->
@@ -170,7 +170,8 @@ let init () =
170170
{loc; txt = Ext_string.uncapitalize_ascii con_name}
171171
(Ext_list.fold_right pcd_args annotate_type (fun x acc ->
172172
Ast_helper.Typ.arrow ~arity:None
173-
{lbl = Nolabel; typ = x} acc)
173+
{attrs = []; lbl = Nolabel; typ = x}
174+
acc)
174175
|> add_arity ~arity))
175176
| Ptype_open | Ptype_abstract ->
176177
Ast_derive_util.not_applicable tdcl.ptype_loc deriving_name;

compiler/frontend/ast_exp_handle_external.ml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let handle_external loc (x : string) : Parsetree.expression =
4343
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
4444
~pval_type:
4545
(Ast_helper.Typ.arrow ~arity:(Some 1)
46-
{lbl = Nolabel; typ = Ast_helper.Typ.any ()}
46+
{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}
4747
(Ast_helper.Typ.any ()))
4848
[str_exp];
4949
}
@@ -72,7 +72,7 @@ let handle_debugger loc (payload : Ast_payload.t) =
7272
Ast_external_mk.local_external_apply loc ~pval_prim:["%debugger"]
7373
~pval_type:
7474
(Ast_helper.Typ.arrow ~arity:(Some 1)
75-
{lbl = Nolabel; typ = Ast_helper.Typ.any ()}
75+
{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}
7676
(Ast_literal.type_unit ()))
7777
[Ast_literal.val_unit ~loc ()]
7878
| _ ->
@@ -99,7 +99,7 @@ let handle_raw ~kind loc payload =
9999
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
100100
~pval_type:
101101
(Ast_helper.Typ.arrow ~arity:(Some 1)
102-
{lbl = Nolabel; typ = Ast_helper.Typ.any ()}
102+
{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}
103103
(Ast_helper.Typ.any ()))
104104
[exp];
105105
pexp_attributes =
@@ -128,11 +128,16 @@ let handle_ffi ~loc ~payload =
128128
let unit = Ast_literal.type_unit ~loc () in
129129
let rec arrow ~arity =
130130
if arity = 0 then
131-
Ast_helper.Typ.arrow ~arity:None ~loc {lbl = Nolabel; typ = unit} any
131+
Ast_helper.Typ.arrow ~arity:None ~loc
132+
{attrs = []; lbl = Nolabel; typ = unit}
133+
any
132134
else if arity = 1 then
133-
Ast_helper.Typ.arrow ~arity:None ~loc {lbl = Nolabel; typ = any} any
135+
Ast_helper.Typ.arrow ~arity:None ~loc
136+
{attrs = []; lbl = Nolabel; typ = any}
137+
any
134138
else
135-
Ast_helper.Typ.arrow ~loc ~arity:None {lbl = Nolabel; typ = any}
139+
Ast_helper.Typ.arrow ~loc ~arity:None
140+
{attrs = []; lbl = Nolabel; typ = any}
136141
(arrow ~arity:(arity - 1))
137142
in
138143
match !is_function with
@@ -152,7 +157,7 @@ let handle_ffi ~loc ~payload =
152157
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
153158
~pval_type:
154159
(Ast_helper.Typ.arrow ~arity:(Some 1)
155-
{lbl = Nolabel; typ = Ast_helper.Typ.any ()}
160+
{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}
156161
(Ast_helper.Typ.any ()))
157162
[exp];
158163
pexp_attributes =
@@ -171,7 +176,7 @@ let handle_raw_structure loc payload =
171176
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_stmt"]
172177
~pval_type:
173178
(Ast_helper.Typ.arrow ~arity:(Some 1)
174-
{lbl = Nolabel; typ = Ast_helper.Typ.any ()}
179+
{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}
175180
(Ast_helper.Typ.any ()))
176181
[exp];
177182
}

0 commit comments

Comments
 (0)