this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add record field references to source linking

Add handling for Texp_field in expressions and Tpat_record in patterns.
Record field references (e.g. x.field, { field = ... } patterns) are
linked to their parent type definition by extracting the type path from
the label_description's result type.

Note: Texp_record (record construction expressions) is not yet handled
as individual field locations within record literals require iterating
the fields array. Tpat_record does iterate through fields to link each
field label individually.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+22
+22
src/loader/typedtree_traverse.cppo.ml
··· 14 14 | Tconstr (p, _, _) -> Some p 15 15 | _ -> None 16 16 17 + (** Extract the type path from a label_description's result type. *) 18 + let type_path_of_label_desc (lbl : Types.label_description) = 19 + match Types.get_desc lbl.lbl_res with 20 + | Tconstr (p, _, _) -> Some p 21 + | _ -> None 22 + 17 23 let expr poses expr = 18 24 let exp_loc = expr.Typedtree.exp_loc in 19 25 if exp_loc.loc_ghost then () ··· 31 37 | Texp_construct (_, cstr_desc, _) -> ( 32 38 #endif 33 39 match type_path_of_constructor_desc cstr_desc with 40 + | Some p -> poses := (Type p, exp_loc) :: !poses 41 + | None -> ()) 42 + #if defined OXCAML 43 + | Texp_field (_, _, _, lbl_desc, _, _) -> ( 44 + #else 45 + | Texp_field (_, _, lbl_desc) -> ( 46 + #endif 47 + match type_path_of_label_desc lbl_desc with 34 48 | Some p -> poses := (Type p, exp_loc) :: !poses 35 49 | None -> ()) 36 50 | _ -> () ··· 70 84 match type_path_of_constructor_desc cstr_desc with 71 85 | Some p -> poses := (Type p, pat_loc) :: !poses 72 86 | None -> ()) 87 + | Tpat_record (fields, _) -> 88 + List.iter (fun (lid, lbl_desc, _) -> 89 + match type_path_of_label_desc lbl_desc with 90 + | Some p -> 91 + let loc = lid.Asttypes.loc in 92 + if not loc.Location.loc_ghost then 93 + poses := (Type p, loc) :: !poses 94 + | None -> ()) fields 73 95 | _ -> () 74 96 in 75 97 ()