wip: synth_field

This commit is contained in:
Mylloon 2023-12-05 20:27:51 +01:00
parent 6bbb1f0996
commit 624590e849
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -235,31 +235,22 @@ and synth_field
-> label Position.located -> ty Position.located list option -> HopixTypes.aty -> label Position.located -> ty Position.located list option -> HopixTypes.aty
= =
fun tenv expr lbl tlist -> fun tenv expr lbl tlist ->
(* TODO *) let expr_type = synth_expression tenv expr in
failwith "synth_field"
(*let expr_type = synth_expression tenv expr in
match expr_type with match expr_type with
| ATyCon(cons,atlist) -> | ATyCon (cons, atlist) ->
( let label_scheme =
(* Impossible car n'est pas dans le mli*) try HopixTypes.lookup_type_scheme_of_label lbl.position lbl.value tenv with
let lbllist = HopixTypes.lookup_information_of_type_constructor lbl.position cons tenv in | HopixTypes.Unbound (pos, Label (LId i)) ->
match lbllist with HopixTypes.type_error pos (Printf.sprintf "Unbound label `%s'." i)
| Record r -> in
if List.mem lbl.value r let arrow =
then try HopixTypes.instantiate_type_scheme label_scheme atlist with
let label_scheme = | HopixTypes.InvalidInstantiation { expected; given } ->
try HopixTypes.lookup_type_scheme_of_label label_pos label_val tenv with invalid_instantiation (Position.position expr) expected given
| HopixTypes.Unbound (pos, Label (LId i)) -> in
HopixTypes.type_error pos (Printf.sprintf "Unbound label `%s'." i) (* TODO: On doit utiliser cons et tlist aussi *)
in snd (HopixTypes.destruct_function_type lbl.position arrow)
try HopixTypes.instantiate_type_scheme label_scheme atlist with | _ as x -> x
| HopixTypes.InvalidInstantiation { expected; given } ->
invalid_instantiation (Position.position expr) expected given
else
failwith "Erreur de label"
)
| _ -> failwith "Ceci n'est pas un label"
*)
and synth_tuple and synth_tuple
: HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty : HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty