File tree 4 files changed +26
-4
lines changed
4 files changed +26
-4
lines changed Original file line number Diff line number Diff line change 15
15
#### :bug : Bug Fix
16
16
17
17
- Fix variance setting for builtin ` dict ` type. Fixes issues around inference. https://github.com/rescript-lang/rescript-compiler/pull/6707
18
+ - Improve error when using '@deriving (accessors)' on a variant with record arguments
18
19
19
20
# 11.1.0-rc.6
20
21
Original file line number Diff line number Diff line change
1
+
2
+ [1;31mWe've found a bug for you![0m
3
+ [36m/.../fixtures/DerivingAccessorsRecordParam.res[0m:[2m2:10-25[0m
4
+
5
+ 1 [2m│[0m @deriving(accessors)
6
+ [1;31m2[0m [2m│[0m type t = [1;31mStruct({a: int})[0m
7
+ 3 [2m│[0m
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.
Original file line number Diff line number Diff line change
1
+ @deriving (accessors )
2
+ type t = Struct ({a : int })
Original file line number Diff line number Diff line change @@ -55,15 +55,20 @@ let init () =
55
55
{
56
56
pcd_name = {loc; txt = con_name } ;
57
57
pcd_args;
58
- pcd_loc = _ ;
58
+ pcd_loc;
59
59
pcd_res;
60
60
}
61
61
->
62
62
(* TODO: add type annotations *)
63
63
let pcd_args =
64
64
match pcd_args with
65
65
| Pcstr_tuple pcd_args -> pcd_args
66
- | Pcstr_record _ -> assert false
66
+ | Pcstr_record _ ->
67
+ Location. raise_errorf ~loc: pcd_loc
68
+ " @deriving(accessors) from a variant record argument \
69
+ is unsupported. Either define the record type \
70
+ separately from the variant type or use a \
71
+ positional argument."
67
72
in
68
73
let little_con_name =
69
74
Ext_string. uncapitalize_ascii con_name
@@ -146,14 +151,19 @@ let init () =
146
151
{
147
152
pcd_name = {loc; txt = con_name } ;
148
153
pcd_args;
149
- pcd_loc = _ ;
154
+ pcd_loc;
150
155
pcd_res;
151
156
}
152
157
->
153
158
let pcd_args =
154
159
match pcd_args with
155
160
| Pcstr_tuple pcd_args -> pcd_args
156
- | Pcstr_record _ -> assert false
161
+ | Pcstr_record _ ->
162
+ Location. raise_errorf ~loc: pcd_loc
163
+ " @deriving(accessors) from a variant record argument \
164
+ is unsupported. Either define the record type \
165
+ separately from the variant type or use a \
166
+ positional argument."
157
167
in
158
168
let arity = pcd_args |> List. length in
159
169
let annotate_type =
You can’t perform that action at this time.
0 commit comments