Skip to content

Commit e2d9f39

Browse files
committed
bs.variadic and bs.send transition
1 parent 980c385 commit e2d9f39

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

jscomp/core/lam.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ exception Not_simple_form
287287
where [wrap] used to be simple instructions
288288
Note that [external] functions are forced to do eta-conversion
289289
when combined with [|>] operator, we need to make sure beta-reduction
290-
is applied though since `[@bs.splice]` needs such guarantee.
291-
Since `[@bs.splice] is the tail position
290+
is applied though since `[@variadic]` needs such guarantee.
291+
Since `[@variadic] is the tail position
292292
*)
293293
let rec is_eta_conversion_exn
294294
params inner_args outer_args : t list =

jscomp/core/lam_compile_external_call.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ val translate_ffi :
4545

4646
(** TODO: document supported attributes
4747
Attributes starting with `js` are reserved
48-
examples: "bs.splice"
48+
examples: "variadic"
4949
*)

jscomp/core/lam_convert.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,15 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
904904
]}
905905
is also wrong.
906906
907-
It seems, we need handle [@bs.splice] earlier
907+
It seems, we need handle [@variadic] earlier
908908
909909
or
910910
{[
911911
(fun x y -> f x y) ([|1;2;3|]) -->
912912
let x0, x1, x2 =1,2,3 in
913913
(fun y -> f [|x0;x1;x2|] y)
914914
]}
915-
But this still need us to know [@bs.splice] in advance
915+
But this still need us to know [@variadic] in advance
916916
917917
918918
we should not remove it immediately, since we have to be careful

jscomp/reserved_attributs.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ to detect unused attributes in the future
66

77

88

9-
return
9+
1010
obj
1111
val
1212
module
1313
scope
14-
variadic
15-
send
16-
new
17-
14+
variadic -- done
15+
send -- done
16+
return -- done
17+
new -- done
1818
get_index -- done
1919
set_index -- done
2020
get -- done

jscomp/syntax/ast_external_process.ml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,9 @@ let parse_external_attributes
324324
*)
325325
| scopes -> { st with scopes = scopes }
326326
end
327-
| "bs.splice" | "bs.variadic" -> {st with splice = true}
328-
| "bs.send" ->
327+
| "bs.splice"
328+
| "bs.variadic" | "variadic" -> {st with splice = true}
329+
| "bs.send" | "send" ->
329330
{ st with val_send = name_from_payload_or_prim ~loc payload}
330331
| "bs.send.pipe"
331332
->
@@ -720,21 +721,21 @@ let external_desc_of_non_obj
720721
return_wrapper = _ ;
721722
} ->
722723
(* PR #2162 - since when we assemble arguments the first argument in
723-
[@@bs.send] is ignored
724+
[@@send] is ignored
724725
*)
725726
begin match arg_type_specs with
726727
| [] ->
727728
Location.raise_errorf
728-
~loc "Ill defined attribute [@@bs.send] (the external needs to be a regular function call with at least one argument)"
729+
~loc "Ill defined attribute @send(the external needs to be a regular function call with at least one argument)"
729730
| {arg_type = Arg_cst _ ; arg_label = _} :: _
730731
->
731732
Location.raise_errorf
732-
~loc "Ill defined attribute [@@bs.send] (first argument can't be const)"
733+
~loc "Ill defined attribute @send(first argument can't be const)"
733734
| _ :: _ ->
734735
Js_send {splice ; name; js_send_scopes = scopes ; pipe = false}
735736
end
736737
| {val_send = #bundle_source; _ }
737-
-> Location.raise_errorf ~loc "You used a FFI attribute that can't be used with [@@bs.send]"
738+
-> Location.raise_errorf ~loc "You used a FFI attribute that can't be used with @send"
738739
| {val_send_pipe = Some _;
739740
(* splice = (false as splice); *)
740741
val_send = `Nm_na;
@@ -909,17 +910,17 @@ let handle_attributes
909910
if i = 0 && splice then
910911
begin match arg_label with
911912
| Optional _ ->
912-
Location.raise_errorf ~loc "[@@@@bs.splice] expect the last type to be a non optional"
913+
Location.raise_errorf ~loc "@@variadic expect the last type to be a non optional"
913914
| Labelled _ | Nolabel
914915
->
915916
if ty.ptyp_desc = Ptyp_any then
916-
Location.raise_errorf ~loc "[@@@@bs.splice] expect the last type to be an array";
917+
Location.raise_errorf ~loc "@@variadic expect the last type to be an array";
917918
if spec_of_ptyp true ty <> Nothing then
918-
Location.raise_errorf ~loc "[@@@@bs.splice] expect the last type to be an array";
919+
Location.raise_errorf ~loc "@@variadic expect the last type to be an array";
919920
match ty.ptyp_desc with
920921
| Ptyp_constr({txt = Lident "array"; _}, [_])
921922
-> ()
922-
| _ -> Location.raise_errorf ~loc "[@@@@bs.splice] expect the last type to be an array";
923+
| _ -> Location.raise_errorf ~loc "@@variadic expect the last type to be an array";
923924
end ;
924925
let (arg_label : External_arg_spec.label_noname), arg_type, new_arg_types =
925926
match arg_label with

jscomp/syntax/external_ffi_types.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ type external_spec =
9696
match ffi with
9797
| Js_get_index _scope -> "@get_index .."
9898
| Js_set_index _scope -> "@set_index .."
99-
| Js_get { js_get_name = s} -> Printf.sprintf "[@@bs.get %S]" s
100-
| Js_set { js_set_name = s} -> Printf.sprintf "[@@bs.set %S]" s
101-
| Js_call v -> Printf.sprintf "[@@bs.val %S]" v.name
102-
| Js_send v -> Printf.sprintf "[@@bs.send %S]" v.name
99+
| Js_get { js_get_name = s} -> Printf.sprintf "[@@get %S]" s
100+
| Js_set { js_set_name = s} -> Printf.sprintf "[@@set %S]" s
101+
| Js_call v -> Printf.sprintf "[@@val %S]" v.name
102+
| Js_send v -> Printf.sprintf "[@@send %S]" v.name
103103
| Js_module_as_fn v -> Printf.sprintf "[@@bs.val %S]" v.external_module_name.bundle
104104
| Js_new v -> Printf.sprintf "[@@new %S]" v.name
105105
| Js_module_as_class v

jscomp/test/demo_binding.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ class type textArea =
106106
external set_interval : (unit -> unit [@bs]) -> float -> unit = "setInterval"
107107
[@@bs.module "@runtime", "Runtime"]
108108

109-
external toFixed : float -> int -> string = "toFixed" [@@bs.send ]
109+
external toFixed : float -> int -> string = "toFixed" [@@send]

0 commit comments

Comments
 (0)