@@ -399,21 +399,27 @@ type response = {
399399}
400400
401401(* A fixed argument means what [@as(value) _] means, so decode it with the
402- same reader. [%raw] is JavaScript source and must be exactly one literal. *)
403- let fixed_arg_type
402+ same reader. [%raw] is JavaScript source and must be exactly one literal.
403+ As for [@as(value) _], attributes such as [@ignore] have no effect next to
404+ the value, so they are reported as unused. *)
405+ let fixed_arg_type ~attrs
404406 ((value , loc ) : Parsetree. fixed_value Location. loc * Location. t ) =
405- match value.txt with
406- | Pfixed_raw source ->
407- let source = Ast_raw. js_source source in
408- if Classify_function. is_fixed_literal source then
409- External_arg_spec. Arg_cst (External_arg_spec. cst_json source)
410- else
411- Location. raise_errorf ~loc: value.loc
412- " The %%raw payload must be a JavaScript literal"
413- | Pfixed_int _ | Pfixed_string _ | Pfixed_template _ | Pfixed_json _ -> (
414- match Ast_attributes. as_const [Ast_fixed_arg. to_attribute ~loc value] with
415- | Some cst -> arg_cst_of_as_const cst
416- | None -> Bs_syntaxerr. err loc Expect_int_or_string_or_json_literal )
407+ let arg_type =
408+ match value.txt with
409+ | Pfixed_raw source ->
410+ let source = Ast_raw. js_source source in
411+ if Classify_function. is_fixed_literal source then
412+ External_arg_spec. Arg_cst (External_arg_spec. cst_json source)
413+ else
414+ Location. raise_errorf ~loc: value.loc
415+ " The %%raw payload must be a JavaScript literal"
416+ | Pfixed_int _ | Pfixed_string _ | Pfixed_template _ | Pfixed_json _ -> (
417+ match Ast_attributes. as_const [Ast_fixed_arg. to_attribute ~loc value] with
418+ | Some cst -> arg_cst_of_as_const cst
419+ | None -> Bs_syntaxerr. err loc Expect_int_or_string_or_json_literal )
420+ in
421+ Bs_ast_invariant. warn_discarded_unused_attributes attrs;
422+ arg_type
417423
418424(* A fixed argument is always passed, so it has nothing to make optional. *)
419425let reject_optional_fixed
@@ -483,7 +489,7 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
483489 in
484490 let obj_arg_type =
485491 match fixed with
486- | Some fixed -> fixed_arg_type fixed
492+ | Some fixed -> fixed_arg_type ~attrs: param_attrs fixed
487493 | None -> refine_obj_arg_type ~nolabel: false ty
488494 in
489495 match obj_arg_type with
@@ -950,7 +956,7 @@ let handle_attributes (loc : Location.t) (type_annotation : Parsetree.core_type)
950956 Ext_list. fold_right arg_types_ty
951957 (([] , [] , 0 ) : External_arg_spec. params * Parsetree. arg list * int )
952958 (fun param_type (arg_type_specs , arg_types , i ) ->
953- let arg_label, _ , ty, fixed = arg_parts param_type in
959+ let arg_label, param_attrs , ty, fixed = arg_parts param_type in
954960 (if i = 0 && splice then
955961 match arg_label with
956962 | Optional _ ->
@@ -989,7 +995,7 @@ let handle_attributes (loc : Location.t) (type_annotation : Parsetree.core_type)
989995 | Labelled _ -> (
990996 let arg_type =
991997 match fixed with
992- | Some fixed -> fixed_arg_type fixed
998+ | Some fixed -> fixed_arg_type ~attrs: param_attrs fixed
993999 | None -> refine_arg_type ~nolabel: false ty
9941000 in
9951001 ( Arg_label ,
@@ -1000,7 +1006,7 @@ let handle_attributes (loc : Location.t) (type_annotation : Parsetree.core_type)
10001006 | Nolabel -> (
10011007 let arg_type =
10021008 match fixed with
1003- | Some fixed -> fixed_arg_type fixed
1009+ | Some fixed -> fixed_arg_type ~attrs: param_attrs fixed
10041010 | None -> refine_arg_type ~nolabel: true ty
10051011 in
10061012 ( Arg_empty ,
0 commit comments