File tree 4 files changed +27
-4
lines changed
4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 12
12
13
13
# 11.1.0-rc.8 (Unreleased)
14
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
+
15
19
# 11.1.0-rc.7
16
20
17
21
#### :bug : Bug Fix
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 @@ -4,6 +4,12 @@ let invalid_config (config : Parsetree.expression) =
4
4
Location. raise_errorf ~loc: config.pexp_loc
5
5
" such configuration is not supported"
6
6
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
+
7
13
type tdcls = Parsetree .type_declaration list
8
14
9
15
let derivingName = " accessors"
@@ -55,15 +61,16 @@ let init () =
55
61
{
56
62
pcd_name = {loc; txt = con_name } ;
57
63
pcd_args;
58
- pcd_loc = _ ;
64
+ pcd_loc;
59
65
pcd_res;
60
66
}
61
67
->
62
68
(* TODO: add type annotations *)
63
69
let pcd_args =
64
70
match pcd_args with
65
71
| Pcstr_tuple pcd_args -> pcd_args
66
- | Pcstr_record _ -> assert false
72
+ | Pcstr_record _ ->
73
+ raise_unsupported_vaiant_record_arg pcd_loc
67
74
in
68
75
let little_con_name =
69
76
Ext_string. uncapitalize_ascii con_name
@@ -146,14 +153,15 @@ let init () =
146
153
{
147
154
pcd_name = {loc; txt = con_name } ;
148
155
pcd_args;
149
- pcd_loc = _ ;
156
+ pcd_loc;
150
157
pcd_res;
151
158
}
152
159
->
153
160
let pcd_args =
154
161
match pcd_args with
155
162
| Pcstr_tuple pcd_args -> pcd_args
156
- | Pcstr_record _ -> assert false
163
+ | Pcstr_record _ ->
164
+ raise_unsupported_vaiant_record_arg pcd_loc
157
165
in
158
166
let arity = pcd_args |> List. length in
159
167
let annotate_type =
You can’t perform that action at this time.
0 commit comments