Skip to content

Commit e32ed70

Browse files
authored
Merge pull request #4638 from rescript-lang/clean_up
clean up the confusing error message over uncurry label
2 parents 8070032 + c04a7c6 commit e32ed70

File tree

7 files changed

+45
-30
lines changed

7 files changed

+45
-30
lines changed

Diff for: jscomp/syntax/ast_exp_apply.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let sane_property_name_check loc s =
6060
Location.raise_errorf ~loc
6161
"property name (%s) can not contain speical character #" s
6262
(* match fn as *)
63-
let view_as_app (fn : exp) s : app_pattern option =
63+
let view_as_app (fn : exp) (s : string list) : app_pattern option =
6464
match fn.pexp_desc with
6565
| Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident op; _}}, args )
6666
when Ext_list.has_string s op

Diff for: jscomp/syntax/bs_syntaxerr.ml

+7-4
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ type error
5050
*)
5151
| Not_supported_directive_in_bs_return
5252
| Expect_opt_in_bs_return_to_opt
53-
| Label_in_uncurried_bs_attribute
53+
| Misplaced_label_syntax
5454
| Optional_in_uncurried_bs_attribute
5555
| Bs_this_simple_pattern
5656
| Bs_uncurried_arity_too_large
5757
let pp_error fmt err =
5858
Format.pp_print_string fmt (match err with
5959
| Bs_uncurried_arity_too_large
6060
-> "Uncurried function supports only up to arity 22"
61-
| Label_in_uncurried_bs_attribute
62-
-> "Uncurried function doesn't support labeled arguments yet"
61+
| Misplaced_label_syntax
62+
-> "Label syntax is not support in this position"
63+
(*
64+
let fn x = ((##) x ~hi) ~lo:1 ~hi:2
65+
*)
6366
| Optional_in_uncurried_bs_attribute
6467
-> "Uncurried function doesn't support optional arguments yet"
6568
| Expect_opt_in_bs_return_to_opt
@@ -144,7 +147,7 @@ let optional_err loc (lbl : Asttypes.arg_label) =
144147

145148
let err_if_label loc (lbl : Asttypes.arg_label) =
146149
if lbl <> Nolabel then
147-
raise (Error (loc, Label_in_uncurried_bs_attribute))
150+
raise (Error (loc, Misplaced_label_syntax))
148151

149152
let err_large_arity loc arity =
150153
if arity > 22 then

Diff for: jscomp/syntax/bs_syntaxerr.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type error
4848
*)
4949
| Not_supported_directive_in_bs_return
5050
| Expect_opt_in_bs_return_to_opt
51-
| Label_in_uncurried_bs_attribute
51+
| Misplaced_label_syntax
5252
| Optional_in_uncurried_bs_attribute
5353
| Bs_this_simple_pattern
5454
| Bs_uncurried_arity_too_large

Diff for: lib/4.06.1/unstable/js_compiler.ml

+9-6
Original file line numberDiff line numberDiff line change
@@ -400863,7 +400863,7 @@ type error
400863400863
*)
400864400864
| Not_supported_directive_in_bs_return
400865400865
| Expect_opt_in_bs_return_to_opt
400866-
| Label_in_uncurried_bs_attribute
400866+
| Misplaced_label_syntax
400867400867
| Optional_in_uncurried_bs_attribute
400868400868
| Bs_this_simple_pattern
400869400869
| Bs_uncurried_arity_too_large
@@ -400938,16 +400938,19 @@ type error
400938400938
*)
400939400939
| Not_supported_directive_in_bs_return
400940400940
| Expect_opt_in_bs_return_to_opt
400941-
| Label_in_uncurried_bs_attribute
400941+
| Misplaced_label_syntax
400942400942
| Optional_in_uncurried_bs_attribute
400943400943
| Bs_this_simple_pattern
400944400944
| Bs_uncurried_arity_too_large
400945400945
let pp_error fmt err =
400946400946
Format.pp_print_string fmt (match err with
400947400947
| Bs_uncurried_arity_too_large
400948400948
-> "Uncurried function supports only up to arity 22"
400949-
| Label_in_uncurried_bs_attribute
400950-
-> "Uncurried function doesn't support labeled arguments yet"
400949+
| Misplaced_label_syntax
400950+
-> "Label syntax is not support in this position"
400951+
(*
400952+
let fn x = ((##) x ~hi) ~lo:1 ~hi:2
400953+
*)
400951400954
| Optional_in_uncurried_bs_attribute
400952400955
-> "Uncurried function doesn't support optional arguments yet"
400953400956
| Expect_opt_in_bs_return_to_opt
@@ -401032,7 +401035,7 @@ let optional_err loc (lbl : Asttypes.arg_label) =
401032401035

401033401036
let err_if_label loc (lbl : Asttypes.arg_label) =
401034401037
if lbl <> Nolabel then
401035-
raise (Error (loc, Label_in_uncurried_bs_attribute))
401038+
raise (Error (loc, Misplaced_label_syntax))
401036401039

401037401040
let err_large_arity loc arity =
401038401041
if arity > 22 then
@@ -407519,7 +407522,7 @@ let sane_property_name_check loc s =
407519407522
Location.raise_errorf ~loc
407520407523
"property name (%s) can not contain speical character #" s
407521407524
(* match fn as *)
407522-
let view_as_app (fn : exp) s : app_pattern option =
407525+
let view_as_app (fn : exp) (s : string list) : app_pattern option =
407523407526
match fn.pexp_desc with
407524407527
| Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident op; _}}, args )
407525407528
when Ext_list.has_string s op

Diff for: lib/4.06.1/unstable/js_refmt_compiler.ml

+9-6
Original file line numberDiff line numberDiff line change
@@ -400863,7 +400863,7 @@ type error
400863400863
*)
400864400864
| Not_supported_directive_in_bs_return
400865400865
| Expect_opt_in_bs_return_to_opt
400866-
| Label_in_uncurried_bs_attribute
400866+
| Misplaced_label_syntax
400867400867
| Optional_in_uncurried_bs_attribute
400868400868
| Bs_this_simple_pattern
400869400869
| Bs_uncurried_arity_too_large
@@ -400938,16 +400938,19 @@ type error
400938400938
*)
400939400939
| Not_supported_directive_in_bs_return
400940400940
| Expect_opt_in_bs_return_to_opt
400941-
| Label_in_uncurried_bs_attribute
400941+
| Misplaced_label_syntax
400942400942
| Optional_in_uncurried_bs_attribute
400943400943
| Bs_this_simple_pattern
400944400944
| Bs_uncurried_arity_too_large
400945400945
let pp_error fmt err =
400946400946
Format.pp_print_string fmt (match err with
400947400947
| Bs_uncurried_arity_too_large
400948400948
-> "Uncurried function supports only up to arity 22"
400949-
| Label_in_uncurried_bs_attribute
400950-
-> "Uncurried function doesn't support labeled arguments yet"
400949+
| Misplaced_label_syntax
400950+
-> "Label syntax is not support in this position"
400951+
(*
400952+
let fn x = ((##) x ~hi) ~lo:1 ~hi:2
400953+
*)
400951400954
| Optional_in_uncurried_bs_attribute
400952400955
-> "Uncurried function doesn't support optional arguments yet"
400953400956
| Expect_opt_in_bs_return_to_opt
@@ -401032,7 +401035,7 @@ let optional_err loc (lbl : Asttypes.arg_label) =
401032401035

401033401036
let err_if_label loc (lbl : Asttypes.arg_label) =
401034401037
if lbl <> Nolabel then
401035-
raise (Error (loc, Label_in_uncurried_bs_attribute))
401038+
raise (Error (loc, Misplaced_label_syntax))
401036401039

401037401040
let err_large_arity loc arity =
401038401041
if arity > 22 then
@@ -407519,7 +407522,7 @@ let sane_property_name_check loc s =
407519407522
Location.raise_errorf ~loc
407520407523
"property name (%s) can not contain speical character #" s
407521407524
(* match fn as *)
407522-
let view_as_app (fn : exp) s : app_pattern option =
407525+
let view_as_app (fn : exp) (s : string list) : app_pattern option =
407523407526
match fn.pexp_desc with
407524407527
| Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident op; _}}, args )
407525407528
when Ext_list.has_string s op

Diff for: lib/4.06.1/unstable/native_ppx.ml

+9-6
Original file line numberDiff line numberDiff line change
@@ -12056,7 +12056,7 @@ type error
1205612056
*)
1205712057
| Not_supported_directive_in_bs_return
1205812058
| Expect_opt_in_bs_return_to_opt
12059-
| Label_in_uncurried_bs_attribute
12059+
| Misplaced_label_syntax
1206012060
| Optional_in_uncurried_bs_attribute
1206112061
| Bs_this_simple_pattern
1206212062
| Bs_uncurried_arity_too_large
@@ -12131,16 +12131,19 @@ type error
1213112131
*)
1213212132
| Not_supported_directive_in_bs_return
1213312133
| Expect_opt_in_bs_return_to_opt
12134-
| Label_in_uncurried_bs_attribute
12134+
| Misplaced_label_syntax
1213512135
| Optional_in_uncurried_bs_attribute
1213612136
| Bs_this_simple_pattern
1213712137
| Bs_uncurried_arity_too_large
1213812138
let pp_error fmt err =
1213912139
Format.pp_print_string fmt (match err with
1214012140
| Bs_uncurried_arity_too_large
1214112141
-> "Uncurried function supports only up to arity 22"
12142-
| Label_in_uncurried_bs_attribute
12143-
-> "Uncurried function doesn't support labeled arguments yet"
12142+
| Misplaced_label_syntax
12143+
-> "Label syntax is not support in this position"
12144+
(*
12145+
let fn x = ((##) x ~hi) ~lo:1 ~hi:2
12146+
*)
1214412147
| Optional_in_uncurried_bs_attribute
1214512148
-> "Uncurried function doesn't support optional arguments yet"
1214612149
| Expect_opt_in_bs_return_to_opt
@@ -12225,7 +12228,7 @@ let optional_err loc (lbl : Asttypes.arg_label) =
1222512228

1222612229
let err_if_label loc (lbl : Asttypes.arg_label) =
1222712230
if lbl <> Nolabel then
12228-
raise (Error (loc, Label_in_uncurried_bs_attribute))
12231+
raise (Error (loc, Misplaced_label_syntax))
1222912232

1223012233
let err_large_arity loc arity =
1223112234
if arity > 22 then
@@ -21456,7 +21459,7 @@ let sane_property_name_check loc s =
2145621459
Location.raise_errorf ~loc
2145721460
"property name (%s) can not contain speical character #" s
2145821461
(* match fn as *)
21459-
let view_as_app (fn : exp) s : app_pattern option =
21462+
let view_as_app (fn : exp) (s : string list) : app_pattern option =
2146021463
match fn.pexp_desc with
2146121464
| Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident op; _}}, args )
2146221465
when Ext_list.has_string s op

Diff for: lib/4.06.1/whole_compiler.ml

+9-6
Original file line numberDiff line numberDiff line change
@@ -291106,7 +291106,7 @@ type error
291106291106
*)
291107291107
| Not_supported_directive_in_bs_return
291108291108
| Expect_opt_in_bs_return_to_opt
291109-
| Label_in_uncurried_bs_attribute
291109+
| Misplaced_label_syntax
291110291110
| Optional_in_uncurried_bs_attribute
291111291111
| Bs_this_simple_pattern
291112291112
| Bs_uncurried_arity_too_large
@@ -291181,16 +291181,19 @@ type error
291181291181
*)
291182291182
| Not_supported_directive_in_bs_return
291183291183
| Expect_opt_in_bs_return_to_opt
291184-
| Label_in_uncurried_bs_attribute
291184+
| Misplaced_label_syntax
291185291185
| Optional_in_uncurried_bs_attribute
291186291186
| Bs_this_simple_pattern
291187291187
| Bs_uncurried_arity_too_large
291188291188
let pp_error fmt err =
291189291189
Format.pp_print_string fmt (match err with
291190291190
| Bs_uncurried_arity_too_large
291191291191
-> "Uncurried function supports only up to arity 22"
291192-
| Label_in_uncurried_bs_attribute
291193-
-> "Uncurried function doesn't support labeled arguments yet"
291192+
| Misplaced_label_syntax
291193+
-> "Label syntax is not support in this position"
291194+
(*
291195+
let fn x = ((##) x ~hi) ~lo:1 ~hi:2
291196+
*)
291194291197
| Optional_in_uncurried_bs_attribute
291195291198
-> "Uncurried function doesn't support optional arguments yet"
291196291199
| Expect_opt_in_bs_return_to_opt
@@ -291275,7 +291278,7 @@ let optional_err loc (lbl : Asttypes.arg_label) =
291275291278

291276291279
let err_if_label loc (lbl : Asttypes.arg_label) =
291277291280
if lbl <> Nolabel then
291278-
raise (Error (loc, Label_in_uncurried_bs_attribute))
291281+
raise (Error (loc, Misplaced_label_syntax))
291279291282

291280291283
let err_large_arity loc arity =
291281291284
if arity > 22 then
@@ -410067,7 +410070,7 @@ let sane_property_name_check loc s =
410067410070
Location.raise_errorf ~loc
410068410071
"property name (%s) can not contain speical character #" s
410069410072
(* match fn as *)
410070-
let view_as_app (fn : exp) s : app_pattern option =
410073+
let view_as_app (fn : exp) (s : string list) : app_pattern option =
410071410074
match fn.pexp_desc with
410072410075
| Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident op; _}}, args )
410073410076
when Ext_list.has_string s op

0 commit comments

Comments
 (0)