@@ -24459,6 +24459,9 @@ module Ast_compatible : sig
24459
24459
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24460
24460
24461
24461
24462
+ type arg_label = string
24463
+
24464
+
24462
24465
type loc = Location.t
24463
24466
type attrs = Parsetree.attribute list
24464
24467
open Parsetree
@@ -24536,6 +24539,9 @@ val fun_ :
24536
24539
pattern ->
24537
24540
expression ->
24538
24541
expression
24542
+
24543
+ val is_arg_label_simple :
24544
+ arg_label -> bool
24539
24545
end = struct
24540
24546
#1 "ast_compatible.ml"
24541
24547
(* Copyright (C) 2018 Authors of BuckleScript
@@ -24568,7 +24574,7 @@ open Parsetree
24568
24574
let default_loc = Location.none
24569
24575
24570
24576
24571
-
24577
+ type arg_label = string
24572
24578
let const_exp_string
24573
24579
?(loc = default_loc)
24574
24580
?(attrs = [])
@@ -24676,6 +24682,8 @@ let fun_
24676
24682
pexp_attributes = attrs;
24677
24683
pexp_desc = Pexp_fun("",None, pat, exp)
24678
24684
}
24685
+
24686
+ let is_arg_label_simple s = s = ""
24679
24687
24680
24688
end
24681
24689
module Ext_utf8 : sig
@@ -29320,7 +29328,8 @@ let arity_of_fun
29320
29328
(e : Parsetree.expression) =
29321
29329
let rec aux (e : Parsetree.expression) =
29322
29330
match e.pexp_desc with
29323
- | Pexp_fun ("", None, pat, e) ->
29331
+ | Pexp_fun (arg_label, _, pat, e)
29332
+ when Ast_compatible.is_arg_label_simple arg_label ->
29324
29333
1 + aux e
29325
29334
| Pexp_fun _
29326
29335
-> Location.raise_errorf
@@ -34194,9 +34203,9 @@ let generic_to_uncurry_exp kind loc (self : Bs_ast_mapper.mapper) pat body
34194
34203
match Ast_attributes.process_attributes_rev body.pexp_attributes with
34195
34204
| Nothing, _ ->
34196
34205
begin match body.pexp_desc with
34197
- | Pexp_fun (label ,_, arg, body)
34206
+ | Pexp_fun (arg_label ,_, arg, body)
34198
34207
->
34199
- if label <> "" then
34208
+ if not (Ast_compatible.is_arg_label_simple arg_label) then
34200
34209
Bs_syntaxerr.err loc Label_in_uncurried_bs_attribute;
34201
34210
aux (self.pat self arg :: acc) body
34202
34211
| _ -> self.expr self body, acc
@@ -34441,8 +34450,10 @@ let ocaml_obj_as_js_object
34441
34450
->
34442
34451
begin match e.pexp_desc with
34443
34452
| Pexp_poly
34444
- (({pexp_desc = Pexp_fun ("", None, pat, e)} ),
34445
- None) ->
34453
+ (({pexp_desc = Pexp_fun (arg_label, _, pat, e)} ),
34454
+ None)
34455
+ when Ast_compatible.is_arg_label_simple arg_label
34456
+ ->
34446
34457
let arity = Ast_pat.arity_of_fun pat e in
34447
34458
let method_type =
34448
34459
generate_arg_type x.pcf_loc mapper label.txt arity in
@@ -34503,8 +34514,10 @@ let ocaml_obj_as_js_object
34503
34514
->
34504
34515
begin match e.pexp_desc with
34505
34516
| Pexp_poly
34506
- (({pexp_desc = Pexp_fun ("", None, pat, e)} as f),
34507
- None) ->
34517
+ (({pexp_desc = Pexp_fun (arg_label, None, pat, e)} as f),
34518
+ None)
34519
+ when Ast_compatible.is_arg_label_simple arg_label
34520
+ ->
34508
34521
let arity = Ast_pat.arity_of_fun pat e in
34509
34522
let alias_type =
34510
34523
if aliased then None
@@ -36699,7 +36712,8 @@ let rec unroll_function_aux
36699
36712
(body : Parsetree.expression) : string list * string =
36700
36713
match body.pexp_desc with
36701
36714
| Pexp_constant(Const_string(block,_)) -> acc, block
36702
- | Pexp_fun("",None,{ppat_desc = Ppat_var s},cont) ->
36715
+ | Pexp_fun(arg_label,_,{ppat_desc = Ppat_var s},cont)
36716
+ when Ast_compatible.is_arg_label_simple arg_label ->
36703
36717
unroll_function_aux (s.txt::acc) cont
36704
36718
| _ ->
36705
36719
Location.raise_errorf ~loc:body.pexp_loc
@@ -36724,7 +36738,9 @@ let handle_extension record_as_js_object e (self : Bs_ast_mapper.mapper)
36724
36738
begin match txt with
36725
36739
| "bs.raw" | "raw" ->
36726
36740
begin match payload with
36727
- | PStr [{pstr_desc = Pstr_eval({pexp_desc = Pexp_fun("",None,pat,body)},_)}]
36741
+ | PStr [
36742
+ {pstr_desc = Pstr_eval({pexp_desc = Pexp_fun(arg_label,_,pat,body)},_)}]
36743
+ when Ast_compatible.is_arg_label_simple arg_label
36728
36744
->
36729
36745
begin match pat.ppat_desc, body.pexp_desc with
36730
36746
| Ppat_construct ({txt = Lident "()"}, None), Pexp_constant(Const_string(block,_))
@@ -38531,7 +38547,8 @@ let rec unsafe_mapper : Bs_ast_mapper.mapper =
38531
38547
| `Exn, pexp_attributes ->
38532
38548
Ast_util.convertBsErrorFunction loc self pexp_attributes cases
38533
38549
end
38534
- | Pexp_fun ("", None, pat , body)
38550
+ | Pexp_fun (arg_label, _, pat , body)
38551
+ when Ast_compatible.is_arg_label_simple arg_label
38535
38552
->
38536
38553
begin match Ast_attributes.process_attributes_rev e.pexp_attributes with
38537
38554
| Nothing, _
0 commit comments