type checking
This commit is contained in:
parent
a01eba04e3
commit
1edd925ed5
1 changed files with 8 additions and 3 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
open HopixAST
|
||||
|
||||
let get_aty (HopixTypes.Scheme (_, aty_value)) : HopixTypes.aty = aty_value
|
||||
|
||||
(** Error messages *)
|
||||
|
||||
let invalid_instantiation pos given expected =
|
||||
|
@ -203,7 +205,9 @@ and check_expression
|
|||
fun env (Position.{ value = e; position = pos } as exp) expected ->
|
||||
match e with
|
||||
| Fun df -> failwith "Students! This is your job! Fun check"
|
||||
| _ -> failwith "Students! This is your job! check_expression wildcard"
|
||||
| _ ->
|
||||
let given = synth_expression env exp in
|
||||
check_equal_types pos ~expected ~given
|
||||
|
||||
and check_value_definition
|
||||
: HopixTypes.typing_environment -> HopixAST.value_definition
|
||||
|
@ -212,10 +216,11 @@ and check_value_definition
|
|||
fun env -> function
|
||||
| SimpleValue (id, ty, ex) ->
|
||||
(match ty with
|
||||
| None -> failwith "Type missing."
|
||||
| None -> failwith "A type is missing."
|
||||
| Some ty' ->
|
||||
(*failwith "Students! This is your job! (check_value_definition | SimpleValue)"*)
|
||||
let tys, _ = Position.located_pos (check_type_scheme env) ty' in
|
||||
let tys, tenv = Position.located_pos (check_type_scheme env) ty' in
|
||||
check_expression tenv ex (get_aty tys);
|
||||
HopixTypes.bind_value (Position.value id) tys env)
|
||||
| RecFunctions _ ->
|
||||
(* Je crois que c'est galère et donc c'est pas grave si on arrive pas
|
||||
|
|
Reference in a new issue