Skip to content

Commit 1cdc5e4

Browse files
authored
Merge branch '11.0_release' into hyphen_jsx_attribute
2 parents ced220c + 4a38f30 commit 1cdc5e4

15 files changed

+82
-15
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@
1010
> - :house: [Internal]
1111
> - :nail_care: [Polish]
1212
13-
# 11.1.0-rc.7 (Unreleased)
13+
# 11.1.0-rc.8 (Unreleased)
14+
15+
#### :bug: Bug Fix
16+
17+
- Improve error when using '@deriving(accessors)' on a variant with record arguments. https://github.com/rescript-lang/rescript-compiler/pull/6712
18+
19+
# 11.1.0-rc.7
20+
21+
#### :bug: Bug Fix
22+
23+
- Fix variance setting for builtin `dict` type. Fixes issues around inference. https://github.com/rescript-lang/rescript-compiler/pull/6707
1424

1525
#### :rocket: New Feature
1626

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/DerivingAccessorsRecordParam.res:2:10-25
4+
5+
1 │ @deriving(accessors)
6+
2 │ type t = Struct({a: int})
7+
3 │
8+
9+
@deriving(accessors) from a variant record argument is unsupported. Either define the record type separately from the variant type or use a positional argument.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/dict_inference.res:4:31-33
4+
5+
2 │ dict->Js.Dict.set("someKey1", 1)
6+
3 │ dict->Js.Dict.set("someKey2", 2)
7+
4 │ dict->Js.Dict.set("someKey2", "2")
8+
5 │
9+
10+
This has type: string
11+
But this function argument is expecting: int
12+
13+
You can convert string to int with Belt.Int.fromString.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@deriving(accessors)
2+
type t = Struct({a: int})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let dict = Js.Dict.empty()
2+
dict->Js.Dict.set("someKey1", 1)
3+
dict->Js.Dict.set("someKey2", 2)
4+
dict->Js.Dict.set("someKey2", "2")

jscomp/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 = "11.1.0-rc.7"
24+
let version = "11.1.0-rc.8"
2525
let header = "// Generated by ReScript, PLEASE EDIT WITH CARE"
2626
let package_name = ref "rescript"

jscomp/frontend/ast_derive_projector.ml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ let invalid_config (config : Parsetree.expression) =
44
Location.raise_errorf ~loc:config.pexp_loc
55
"such configuration is not supported"
66

7+
let raise_unsupported_vaiant_record_arg loc =
8+
Location.raise_errorf ~loc
9+
"@deriving(accessors) from a variant record argument is unsupported. \
10+
Either define the record type separately from the variant type or use a \
11+
positional argument."
12+
713
type tdcls = Parsetree.type_declaration list
814

915
let derivingName = "accessors"
@@ -55,15 +61,16 @@ let init () =
5561
{
5662
pcd_name = {loc; txt = con_name};
5763
pcd_args;
58-
pcd_loc = _;
64+
pcd_loc;
5965
pcd_res;
6066
}
6167
->
6268
(* TODO: add type annotations *)
6369
let pcd_args =
6470
match pcd_args with
6571
| Pcstr_tuple pcd_args -> pcd_args
66-
| Pcstr_record _ -> assert false
72+
| Pcstr_record _ ->
73+
raise_unsupported_vaiant_record_arg pcd_loc
6774
in
6875
let little_con_name =
6976
Ext_string.uncapitalize_ascii con_name
@@ -146,14 +153,15 @@ let init () =
146153
{
147154
pcd_name = {loc; txt = con_name};
148155
pcd_args;
149-
pcd_loc = _;
156+
pcd_loc;
150157
pcd_res;
151158
}
152159
->
153160
let pcd_args =
154161
match pcd_args with
155162
| Pcstr_tuple pcd_args -> pcd_args
156-
| Pcstr_record _ -> assert false
163+
| Pcstr_record _ ->
164+
raise_unsupported_vaiant_record_arg pcd_loc
157165
in
158166
let arity = pcd_args |> List.length in
159167
let annotate_type =

jscomp/ml/predef.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ let common_initial_env add_type add_extension empty_env =
238238
{decl_abstr with
239239
type_params = [tvar];
240240
type_arity = 1;
241-
type_variance = [Variance.covariant]}
241+
type_variance = [Variance.full]}
242242
and decl_uncurried =
243243
let tvar1, tvar2 = newgenvar(), newgenvar() in
244244
{decl_abstr with

jscomp/runtime/release.ninja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ o runtime/caml_exceptions.cmj : cc_cmi runtime/caml_exceptions.res | runtime/cam
2525
o runtime/caml_exceptions.cmi : cc runtime/caml_exceptions.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
2626
o runtime/caml_float.cmj : cc_cmi runtime/caml_float.res | runtime/caml_float.cmi runtime/caml_float_extern.cmj
2727
o runtime/caml_float.cmi : cc runtime/caml_float.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
28-
o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml.cmj runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj
28+
o runtime/caml_format.cmj : cc_cmi runtime/caml_format.ml | runtime/caml_float.cmj runtime/caml_float_extern.cmj runtime/caml_format.cmi runtime/caml_int64.cmj runtime/caml_int64_extern.cmj runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmj
2929
o runtime/caml_format.cmi : cc runtime/caml_format.mli | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
3030
o runtime/caml_hash.cmj : cc_cmi runtime/caml_hash.res | runtime/caml_hash.cmi runtime/caml_hash_primitive.cmj runtime/caml_nativeint_extern.cmj runtime/js.cmj
3131
o runtime/caml_hash.cmi : cc runtime/caml_hash.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
@@ -41,7 +41,7 @@ o runtime/caml_md5.cmj : cc_cmi runtime/caml_md5.res | runtime/caml_array_extern
4141
o runtime/caml_md5.cmi : cc runtime/caml_md5.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
4242
o runtime/caml_module.cmj : cc_cmi runtime/caml_module.res | runtime/caml_array_extern.cmj runtime/caml_module.cmi runtime/caml_obj.cmj
4343
o runtime/caml_module.cmi : cc runtime/caml_module.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
44-
o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.res | runtime/caml.cmj runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj
44+
o runtime/caml_obj.cmj : cc_cmi runtime/caml_obj.res | runtime/caml_array_extern.cmj runtime/caml_obj.cmi runtime/caml_option.cmj runtime/js.cmj
4545
o runtime/caml_obj.cmi : cc runtime/caml_obj.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
4646
o runtime/caml_option.cmj : cc_cmi runtime/caml_option.res | runtime/caml_option.cmi runtime/caml_undefined_extern.cmj runtime/js.cmj
4747
o runtime/caml_option.cmi : cc runtime/caml_option.resi | runtime/bs_stdlib_mini.cmi runtime/caml_undefined_extern.cmj runtime/js.cmi runtime/js.cmj
@@ -58,7 +58,7 @@ o runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj : cc runtime/cam
5858
o runtime/caml_external_polyfill.cmi runtime/caml_external_polyfill.cmj : cc runtime/caml_external_polyfill.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
5959
o runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj : cc runtime/caml_float_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6060
o runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj : cc runtime/caml_int64_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
61-
o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.res | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/caml_option.cmj runtime/js.cmi runtime/js.cmj
61+
o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.res | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/js.cmi runtime/js.cmj
6262
o runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj : cc runtime/caml_nativeint_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6363
o runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj : cc runtime/caml_string_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6464
o runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj : cc runtime/caml_undefined_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj

jscomp/test/DictInference.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/DictInference.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let dict = Js.Dict.empty()
2+
dict->Js.Dict.set("someKey1", 1)
3+
dict->Js.Dict.set("someKey2", 2)
4+
let asArray = dict->Js.Dict.values

jscomp/test/build.ninja

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rescript",
3-
"version": "11.1.0-rc.7",
3+
"version": "11.1.0-rc.8",
44
"devDependencies": {
55
"mocha": "10.1.0",
66
"nyc": "15.0.0",

packages/std/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rescript/std",
3-
"version": "11.1.0-rc.7",
3+
"version": "11.1.0-rc.8",
44
"keywords": [
55
"rescript",
66
"stdlib",

0 commit comments

Comments
 (0)