@@ -60,7 +60,12 @@ let () =
60
60
Ast_derive_js_mapper. init ()
61
61
62
62
63
-
63
+ let succeed attr attrs =
64
+ match attrs with
65
+ | [ _ ] -> ()
66
+ | _ ->
67
+ Bs_ast_invariant. mark_used_bs_attribute attr;
68
+ Bs_ast_invariant. warn_discarded_unused_attributes attrs
64
69
65
70
type mapper = Bs_ast_mapper .mapper
66
71
let default_mapper = Bs_ast_mapper. default_mapper
@@ -243,14 +248,14 @@ let signature_item_mapper (self : mapper) (sigi : Parsetree.signature_item) =
243
248
Ast_external. handleExternalInSig self value_desc sigi
244
249
else
245
250
(match
246
- Ast_attributes. has_inline_payload_in_sig
251
+ Ast_attributes. has_inline_payload
247
252
pval_attributes with
248
- | Some (_ ,PStr [{pstr_desc = Pstr_eval ({pexp_desc } ,_ )} ]) ->
253
+ | Some (( _ ,PStr [{pstr_desc = Pstr_eval ({pexp_desc } ,_ )} ]) as attr ) ->
249
254
begin match pexp_desc with
250
255
| Pexp_constant (
251
256
Pconst_string
252
257
(s,dec)) ->
253
- Bs_ast_invariant. warn_discarded_unused_attributes pval_attributes;
258
+ succeed attr pval_attributes;
254
259
{ sigi with
255
260
psig_desc = Psig_value
256
261
{
@@ -260,8 +265,8 @@ let signature_item_mapper (self : mapper) (sigi : Parsetree.signature_item) =
260
265
}}
261
266
| Pexp_constant (
262
267
Pconst_integer (s,None )
263
- ) ->
264
- Bs_ast_invariant. warn_discarded_unused_attributes pval_attributes;
268
+ ) ->
269
+ succeed attr pval_attributes;
265
270
let s = Int32. of_string s in
266
271
{ sigi with
267
272
psig_desc = Psig_value
@@ -273,22 +278,22 @@ let signature_item_mapper (self : mapper) (sigi : Parsetree.signature_item) =
273
278
| Pexp_constant (Pconst_integer (s, Some 'L' ))
274
279
->
275
280
let s = Int64. of_string s in
276
- Bs_ast_invariant. warn_discarded_unused_attributes pval_attributes;
281
+ succeed attr pval_attributes;
277
282
{sigi with psig_desc = Psig_value {
278
283
value_desc with
279
284
pval_prim = External_ffi_types. inline_int64_primitive s;
280
285
pval_attributes = [] ;
281
286
} }
282
287
| Pexp_constant (Pconst_float(s ,None)) ->
283
- Bs_ast_invariant. warn_discarded_unused_attributes pval_attributes;
288
+ succeed attr pval_attributes;
284
289
{sigi with psig_desc = Psig_value {
285
290
value_desc with
286
291
pval_prim = External_ffi_types. inline_float_primitive s;
287
292
pval_attributes = [] ;
288
293
} }
289
294
| Pexp_construct ({txt = Lident (" true" | " false" as txt)}, None )
290
295
->
291
- Bs_ast_invariant. warn_discarded_unused_attributes pval_attributes;
296
+ succeed attr pval_attributes;
292
297
{ sigi with
293
298
psig_desc = Psig_value
294
299
{
@@ -326,54 +331,54 @@ let structure_item_mapper (self : mapper) (str : Parsetree.structure_item) =
326
331
->
327
332
let pvb_expr = self.expr self pvb_expr in
328
333
let pvb_attributes = self.attributes self pvb_attributes in
329
- let has_inline_property = Ast_attributes. has_inline_in_stru pvb_attributes in
334
+ let has_inline_property = Ast_attributes. has_inline_payload pvb_attributes in
330
335
begin match has_inline_property, pvb_expr.pexp_desc with
331
- | true , Pexp_constant (
336
+ | Some attr , Pexp_constant (
332
337
Pconst_string
333
338
(s,dec))
334
339
->
335
- Bs_ast_invariant. warn_discarded_unused_attributes pvb_attributes;
340
+ succeed attr pvb_attributes;
336
341
{str with pstr_desc = Pstr_primitive {
337
342
pval_name = pval_name ;
338
343
pval_type = Ast_literal. type_string () ;
339
344
pval_loc = pvb_loc;
340
345
pval_attributes = [] ;
341
346
pval_prim = External_ffi_types. inline_string_primitive s dec
342
347
} }
343
- | true , Pexp_constant (Pconst_integer (s,None ))
348
+ | Some attr , Pexp_constant (Pconst_integer (s,None ))
344
349
->
345
350
let s = Int32. of_string s in
346
- Bs_ast_invariant. warn_discarded_unused_attributes pvb_attributes;
351
+ succeed attr pvb_attributes;
347
352
{str with pstr_desc = Pstr_primitive {
348
353
pval_name = pval_name ;
349
354
pval_type = Ast_literal. type_int () ;
350
355
pval_loc = pvb_loc;
351
356
pval_attributes = [] ;
352
357
pval_prim = External_ffi_types. inline_int_primitive s
353
358
} }
354
- | true , Pexp_constant (Pconst_integer (s, Some 'L' ))
359
+ | Some attr , Pexp_constant (Pconst_integer (s, Some 'L' ))
355
360
->
356
361
let s = Int64. of_string s in
357
- Bs_ast_invariant. warn_discarded_unused_attributes pvb_attributes;
362
+ succeed attr pvb_attributes;
358
363
{str with pstr_desc = Pstr_primitive {
359
364
pval_name = pval_name ;
360
365
pval_type = Ast_literal. type_int64;
361
366
pval_loc = pvb_loc;
362
367
pval_attributes = [] ;
363
368
pval_prim = External_ffi_types. inline_int64_primitive s
364
369
} }
365
- | true , Pexp_constant (Pconst_float (s, None ))
370
+ | Some attr , Pexp_constant (Pconst_float (s, None ))
366
371
->
367
- Bs_ast_invariant. warn_discarded_unused_attributes pvb_attributes;
372
+ succeed attr pvb_attributes;
368
373
{str with pstr_desc = Pstr_primitive {
369
374
pval_name = pval_name ;
370
375
pval_type = Ast_literal. type_float;
371
376
pval_loc = pvb_loc;
372
377
pval_attributes = [] ;
373
378
pval_prim = External_ffi_types. inline_float_primitive s
374
379
} }
375
- | true , Pexp_construct ({txt = Lident ("true" | "false" as txt ) } ,None ) ->
376
- Bs_ast_invariant. warn_discarded_unused_attributes pvb_attributes;
380
+ | Some attr , Pexp_construct ({txt = Lident ("true" | "false" as txt ) } ,None ) ->
381
+ succeed attr pvb_attributes;
377
382
{str with pstr_desc = Pstr_primitive {
378
383
pval_name = pval_name ;
379
384
pval_type = Ast_literal. type_bool () ;
0 commit comments