Skip to content

Commit 5c5f2bd

Browse files
committed
Reuse process_tag_type instead of duplicating logic in process_as_name
1 parent 14c1bdb commit 5c5f2bd

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

compiler/ml/ast_untagged_variants.ml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,6 @@ let process_tag_name (attrs : Parsetree.attributes) =
323323
| _ -> ());
324324
!st
325325

326-
let process_as_name (attrs : Parsetree.attributes) =
327-
let st = ref None in
328-
Ext_list.iter attrs (fun ({txt; loc}, payload) ->
329-
match txt with
330-
| "as" ->
331-
if !st = None then
332-
match Ast_payload.is_single_string payload with
333-
| None -> ()
334-
| Some (s, _dec) -> st := Some s
335-
else raise (Error (loc, Duplicated_bs_as))
336-
| _ -> ());
337-
!st
338-
339326
let get_tag_name (cstr : Types.constructor_declaration) =
340327
process_tag_name cstr.cd_attributes
341328

@@ -496,9 +483,9 @@ let check_tag_field_conflicts (cstrs : Types.constructor_declaration list) =
496483
(fun (field : Types.label_declaration) ->
497484
(* Get the effective field name in JavaScript output *)
498485
let effective_field_name =
499-
match process_as_name field.ld_attributes with
500-
| Some as_name -> as_name (* Use @as name if present *)
501-
| None -> Ident.name field.ld_id (* Otherwise use field name *)
486+
match process_tag_type field.ld_attributes with
487+
| Some (String as_name) -> as_name (* Use @as name if present *)
488+
| _ -> Ident.name field.ld_id (* Otherwise use field name *)
502489
in
503490
(* Check if effective field name conflicts with tag *)
504491
if effective_field_name = tag_name then

0 commit comments

Comments
 (0)