Skip to content

Commit d4f702d

Browse files
actually use the implicit_id during implicit resolution
1 parent 3656304 commit d4f702d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/mo_frontend/typing.ml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,7 @@ type hole_candidate =
13491349
desc: string;
13501350
typ : T.typ;
13511351
module_name_opt: string option;
1352+
implicit_id : T.lab option;
13521353
id : T.lab;
13531354
region : Source.region;
13541355
}
@@ -1418,9 +1419,9 @@ type hole_error =
14181419
| HoleAmbiguous of (env -> unit)
14191420

14201421
let resolve_hole env at hole_sort typ =
1421-
let is_matching_lab lab =
1422+
let is_matching_lab candidate =
14221423
match hole_sort with
1423-
| Named lab1 -> String.starts_with ~prefix:lab1 lab
1424+
| Named lab1 -> String.equal lab1 (Option.value ~default:candidate.id candidate.implicit_id)
14241425
| Anon _ -> true
14251426
in
14261427

@@ -1431,27 +1432,28 @@ let resolve_hole env at hole_sort typ =
14311432
| T.{ lab; typ = Mut t; _ } -> None
14321433
| T.{ lab = lab1; implicit_lab; typ = typ1; src } ->
14331434
if is_matching_typ typ1
1434-
then Some (Option.value ~default:lab1 implicit_lab , typ1, src.T.region)
1435+
then Some (lab1, implicit_lab, typ1, src.T.region)
14351436
else None
14361437
in
14371438
let find_candidate_fields in_libs (module_name, (_, fs)) =
14381439
List.filter_map has_matching_field_typ fs |>
1439-
List.map (fun (lab, typ, region)->
1440+
List.map (fun (id, implicit_id, typ, region)->
14401441
let path =
14411442
{ it = DotE(
14421443
{ it = module_exp in_libs env module_name;
14431444
at = Source.no_region;
14441445
note = empty_typ_note
14451446
},
1446-
{ it = lab; at = no_region; note = () },
1447+
{ it = id; at = no_region; note = () },
14471448
ref None);
14481449
at = Source.no_region;
14491450
note = empty_typ_note; }
14501451
in
1451-
({ path; desc = quote (module_name^"."^ lab); typ; module_name_opt = Some module_name; id=lab; region } : hole_candidate))
1452+
({ desc = quote (module_name ^ "." ^ id);
1453+
module_name_opt = Some module_name;
1454+
path; typ; id; implicit_id; region }))
14521455
in
14531456
let find_candidate_id = function
1454-
(* TODO use implicit_id *)
14551457
(id, (implicit_id, t, region, _, _)) ->
14561458
if is_matching_typ t
14571459
then
@@ -1460,22 +1462,22 @@ let resolve_hole env at hole_sort typ =
14601462
at = Source.no_region;
14611463
note = empty_typ_note }
14621464
in
1463-
Some { path; desc = quote id; typ = t; module_name_opt = None; id; region }
1465+
Some { path; desc = quote id; typ = t; module_name_opt = None; id; implicit_id; region }
14641466
else None
14651467
in
14661468
let (eligible_ids, explicit_ids) =
14671469
T.Env.to_seq env.vals |>
14681470
Seq.filter_map find_candidate_id |>
14691471
List.of_seq |>
1470-
List.partition (fun (desc : hole_candidate) -> is_matching_lab desc.id)
1472+
List.partition is_matching_lab
14711473
in
14721474
let candidates in_libs xs f =
14731475
T.Env.to_seq xs |>
14741476
Seq.filter_map f |>
14751477
Seq.map (find_candidate_fields in_libs) |>
14761478
List.of_seq |>
14771479
List.flatten |>
1478-
List.partition (fun (desc : hole_candidate) -> is_matching_lab desc.id)
1480+
List.partition is_matching_lab
14791481
in
14801482
let eligible_terms, explicit_terms =
14811483
match eligible_ids with

0 commit comments

Comments
 (0)