TypeAnnot

This commit is contained in:
Nicolas PENELOUX 2023-12-05 22:07:53 +01:00
parent cfbaa90ed9
commit fbd63b1c5d

View file

@ -137,7 +137,7 @@ and pattern_literal
: HopixTypes.typing_environment -> HopixAST.literal Position.located
-> HopixTypes.aty * HopixTypes.typing_environment
=
fun tenv l -> failwith "synth_pattern | Pliteral"
fun tenv l -> synth_literal l.value, tenv
and pattern_variable : Position.t -> HopixTypes.aty * HopixTypes.typing_environment =
fun pos -> HopixTypes.type_error pos "No types found."
@ -146,7 +146,13 @@ and pattern_tannot
: HopixTypes.typing_environment -> HopixAST.pattern Position.located
-> HopixAST.ty Position.located -> HopixTypes.aty * HopixTypes.typing_environment
=
fun tenv p ty -> failwith "synth_pattern | PTypeAnnot"
fun tenv p ty ->
let aty_of_ty = HopixTypes.internalize_ty tenv ty in
match p.value with
| PWildcard -> aty_of_ty, tenv
| PVariable i -> aty_of_ty,HopixTypes.bind_value i.value (HopixTypes.monomorphic_type_scheme aty_of_ty) tenv
| _ -> let pattern_type, tenv = synth_pattern tenv p in
check_equal_types p.position ~expected:aty_of_ty ~given:pattern_type; pattern_type, tenv
and pattern_tuple
: HopixTypes.typing_environment -> HopixAST.pattern Position.located list