Merge branch 'jalon3' of gaufre.informatique.univ-paris-diderot.fr:Anri/compilation-m1-2023 into jalon3

This commit is contained in:
Nicolas PENELOUX 2023-12-05 20:48:41 +01:00
commit 90bec5c08d

View file

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