File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,19 @@ 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+
326339let get_tag_name (cstr : Types.constructor_declaration ) =
327340 process_tag_name cstr.cd_attributes
328341
@@ -475,8 +488,15 @@ let check_tag_field_conflicts (cstrs : Types.constructor_declaration list) =
475488 match cstr.cd_args with
476489 | Cstr_record fields ->
477490 List. iter (fun (field : Types.label_declaration ) ->
478- if Ident. name field.ld_id = tag_name then
491+ (* Check if field name conflicts with tag *)
492+ let field_name = Ident. name field.ld_id in
493+ if field_name = tag_name then
494+ raise (Error (cstr.cd_loc, TagFieldNameConflict (Ident. name cstr.cd_id, tag_name)));
495+ (* Check if @as name conflicts with tag *)
496+ match process_as_name field.ld_attributes with
497+ | Some as_name when as_name = tag_name ->
479498 raise (Error (cstr.cd_loc, TagFieldNameConflict (Ident. name cstr.cd_id, tag_name)))
499+ | _ -> ()
480500 ) fields
481501 | _ -> () )
482502 | None -> ()
You can’t perform that action at this time.
0 commit comments