Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jscomp/syntax/ast_derive_js_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ let eraseTypeStr =
)
let unsafeIndex = "_index"
let unsafeIndexGet =
let any = Typ.any () in
Str.primitive
(Val.mk ~prim:[""] {loc = noloc; txt = unsafeIndex} ~attrs:[Ast_attributes.bs_get_index]
(Ast_compatible.arrow (Typ.var "b") (Ast_compatible.arrow (Typ.var "a") (Typ.var "c")))
(Ast_compatible.arrow any (Ast_compatible.arrow any any))
)
let unsafeIndexGetExp = (Exp.ident {loc = noloc; txt = Lident unsafeIndex})
(* JavaScript has allowed trailing commas in array literals since the beginning,
Expand Down
29 changes: 16 additions & 13 deletions jscomp/syntax/ast_external_process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,24 @@ let refine_arg_type ~(nolabel:bool) (ptyp : Ast_core_type.t)
(if ptyp.ptyp_desc = Ptyp_any then
let ptyp_attrs = ptyp.ptyp_attributes in
let result = Ast_attributes.iter_process_bs_string_or_int_as ptyp_attrs in
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
match result with
| None ->
Bs_syntaxerr.err ptyp.ptyp_loc Invalid_underscore_type_in_external
| Some (Int i) -> (* (_[@bs.as ])*)
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Some (Str i)->
Arg_cst (External_arg_spec.cst_string i)
| Some (Js_literal_str s) ->
Arg_cst (External_arg_spec.cst_obj_literal s)
spec_of_ptyp nolabel ptyp
| Some cst -> (* (_[@bs.as ])*)
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
begin match cst with
| Int i ->
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Str i->
Arg_cst (External_arg_spec.cst_string i)
| Js_literal_str s ->
Arg_cst (External_arg_spec.cst_obj_literal s)
end
else (* ([`a|`b] [@bs.string]) *)
spec_of_ptyp nolabel ptyp
)
Expand Down
32 changes: 18 additions & 14 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -404951,9 +404951,10 @@ let eraseTypeStr =
)
let unsafeIndex = "_index"
let unsafeIndexGet =
let any = Typ.any () in
Str.primitive
(Val.mk ~prim:[""] {loc = noloc; txt = unsafeIndex} ~attrs:[Ast_attributes.bs_get_index]
(Ast_compatible.arrow (Typ.var "b") (Ast_compatible.arrow (Typ.var "a") (Typ.var "c")))
(Ast_compatible.arrow any (Ast_compatible.arrow any any))
)
let unsafeIndexGetExp = (Exp.ident {loc = noloc; txt = Lident unsafeIndex})
(* JavaScript has allowed trailing commas in array literals since the beginning,
Expand Down Expand Up @@ -406021,21 +406022,24 @@ let refine_arg_type ~(nolabel:bool) (ptyp : Ast_core_type.t)
(if ptyp.ptyp_desc = Ptyp_any then
let ptyp_attrs = ptyp.ptyp_attributes in
let result = Ast_attributes.iter_process_bs_string_or_int_as ptyp_attrs in
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
match result with
| None ->
Bs_syntaxerr.err ptyp.ptyp_loc Invalid_underscore_type_in_external
| Some (Int i) -> (* (_[@bs.as ])*)
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Some (Str i)->
Arg_cst (External_arg_spec.cst_string i)
| Some (Js_literal_str s) ->
Arg_cst (External_arg_spec.cst_obj_literal s)
spec_of_ptyp nolabel ptyp
| Some cst -> (* (_[@bs.as ])*)
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
begin match cst with
| Int i ->
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Str i->
Arg_cst (External_arg_spec.cst_string i)
| Js_literal_str s ->
Arg_cst (External_arg_spec.cst_obj_literal s)
end
else (* ([`a|`b] [@bs.string]) *)
spec_of_ptyp nolabel ptyp
)
Expand Down
32 changes: 18 additions & 14 deletions lib/4.06.1/unstable/js_refmt_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -404951,9 +404951,10 @@ let eraseTypeStr =
)
let unsafeIndex = "_index"
let unsafeIndexGet =
let any = Typ.any () in
Str.primitive
(Val.mk ~prim:[""] {loc = noloc; txt = unsafeIndex} ~attrs:[Ast_attributes.bs_get_index]
(Ast_compatible.arrow (Typ.var "b") (Ast_compatible.arrow (Typ.var "a") (Typ.var "c")))
(Ast_compatible.arrow any (Ast_compatible.arrow any any))
)
let unsafeIndexGetExp = (Exp.ident {loc = noloc; txt = Lident unsafeIndex})
(* JavaScript has allowed trailing commas in array literals since the beginning,
Expand Down Expand Up @@ -406021,21 +406022,24 @@ let refine_arg_type ~(nolabel:bool) (ptyp : Ast_core_type.t)
(if ptyp.ptyp_desc = Ptyp_any then
let ptyp_attrs = ptyp.ptyp_attributes in
let result = Ast_attributes.iter_process_bs_string_or_int_as ptyp_attrs in
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
match result with
| None ->
Bs_syntaxerr.err ptyp.ptyp_loc Invalid_underscore_type_in_external
| Some (Int i) -> (* (_[@bs.as ])*)
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Some (Str i)->
Arg_cst (External_arg_spec.cst_string i)
| Some (Js_literal_str s) ->
Arg_cst (External_arg_spec.cst_obj_literal s)
spec_of_ptyp nolabel ptyp
| Some cst -> (* (_[@bs.as ])*)
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
begin match cst with
| Int i ->
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Str i->
Arg_cst (External_arg_spec.cst_string i)
| Js_literal_str s ->
Arg_cst (External_arg_spec.cst_obj_literal s)
end
else (* ([`a|`b] [@bs.string]) *)
spec_of_ptyp nolabel ptyp
)
Expand Down
29 changes: 16 additions & 13 deletions lib/4.06.1/unstable/native_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18569,21 +18569,24 @@ let refine_arg_type ~(nolabel:bool) (ptyp : Ast_core_type.t)
(if ptyp.ptyp_desc = Ptyp_any then
let ptyp_attrs = ptyp.ptyp_attributes in
let result = Ast_attributes.iter_process_bs_string_or_int_as ptyp_attrs in
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
match result with
| None ->
Bs_syntaxerr.err ptyp.ptyp_loc Invalid_underscore_type_in_external
| Some (Int i) -> (* (_[@bs.as ])*)
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Some (Str i)->
Arg_cst (External_arg_spec.cst_string i)
| Some (Js_literal_str s) ->
Arg_cst (External_arg_spec.cst_obj_literal s)
spec_of_ptyp nolabel ptyp
| Some cst -> (* (_[@bs.as ])*)
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
begin match cst with
| Int i ->
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Str i->
Arg_cst (External_arg_spec.cst_string i)
| Js_literal_str s ->
Arg_cst (External_arg_spec.cst_obj_literal s)
end
else (* ([`a|`b] [@bs.string]) *)
spec_of_ptyp nolabel ptyp
)
Expand Down
32 changes: 18 additions & 14 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -407499,9 +407499,10 @@ let eraseTypeStr =
)
let unsafeIndex = "_index"
let unsafeIndexGet =
let any = Typ.any () in
Str.primitive
(Val.mk ~prim:[""] {loc = noloc; txt = unsafeIndex} ~attrs:[Ast_attributes.bs_get_index]
(Ast_compatible.arrow (Typ.var "b") (Ast_compatible.arrow (Typ.var "a") (Typ.var "c")))
(Ast_compatible.arrow any (Ast_compatible.arrow any any))
)
let unsafeIndexGetExp = (Exp.ident {loc = noloc; txt = Lident unsafeIndex})
(* JavaScript has allowed trailing commas in array literals since the beginning,
Expand Down Expand Up @@ -408569,21 +408570,24 @@ let refine_arg_type ~(nolabel:bool) (ptyp : Ast_core_type.t)
(if ptyp.ptyp_desc = Ptyp_any then
let ptyp_attrs = ptyp.ptyp_attributes in
let result = Ast_attributes.iter_process_bs_string_or_int_as ptyp_attrs in
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
match result with
| None ->
Bs_syntaxerr.err ptyp.ptyp_loc Invalid_underscore_type_in_external
| Some (Int i) -> (* (_[@bs.as ])*)
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Some (Str i)->
Arg_cst (External_arg_spec.cst_string i)
| Some (Js_literal_str s) ->
Arg_cst (External_arg_spec.cst_obj_literal s)
spec_of_ptyp nolabel ptyp
| Some cst -> (* (_[@bs.as ])*)
(* when ppx start dropping attributes
we should warn, there is a trade off whether
we should warn dropped non bs attribute or not
*)
Bs_ast_invariant.warn_discarded_unused_attributes ptyp_attrs;
begin match cst with
| Int i ->
(* This type is used in bs.obj only to construct obj type*)
Arg_cst(External_arg_spec.cst_int i)
| Str i->
Arg_cst (External_arg_spec.cst_string i)
| Js_literal_str s ->
Arg_cst (External_arg_spec.cst_obj_literal s)
end
else (* ([`a|`b] [@bs.string]) *)
spec_of_ptyp nolabel ptyp
)
Expand Down