wip: synth_field
This commit is contained in:
parent
6bbb1f0996
commit
624590e849
1 changed files with 15 additions and 24 deletions
|
@ -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) ->
|
||||||
(
|
|
||||||
(* 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 =
|
let label_scheme =
|
||||||
try HopixTypes.lookup_type_scheme_of_label label_pos label_val tenv with
|
try HopixTypes.lookup_type_scheme_of_label lbl.position lbl.value tenv with
|
||||||
| HopixTypes.Unbound (pos, Label (LId i)) ->
|
| HopixTypes.Unbound (pos, Label (LId i)) ->
|
||||||
HopixTypes.type_error pos (Printf.sprintf "Unbound label `%s'." i)
|
HopixTypes.type_error pos (Printf.sprintf "Unbound label `%s'." i)
|
||||||
in
|
in
|
||||||
|
let arrow =
|
||||||
try HopixTypes.instantiate_type_scheme label_scheme atlist with
|
try HopixTypes.instantiate_type_scheme label_scheme atlist with
|
||||||
| HopixTypes.InvalidInstantiation { expected; given } ->
|
| HopixTypes.InvalidInstantiation { expected; given } ->
|
||||||
invalid_instantiation (Position.position expr) expected given
|
invalid_instantiation (Position.position expr) expected given
|
||||||
else
|
in
|
||||||
failwith "Erreur de label"
|
(* TODO: On doit utiliser cons et tlist aussi *)
|
||||||
)
|
snd (HopixTypes.destruct_function_type lbl.position arrow)
|
||||||
| _ -> failwith "Ceci n'est pas un label"
|
| _ as x -> x
|
||||||
*)
|
|
||||||
|
|
||||||
and synth_tuple
|
and synth_tuple
|
||||||
: HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty
|
: HopixTypes.typing_environment -> expression Position.located list -> HopixTypes.aty
|
||||||
|
|
Reference in a new issue