From fbd63b1c5db139f67b66bd519e400dcc39328260 Mon Sep 17 00:00:00 2001 From: Nicolas PENELOUX Date: Tue, 5 Dec 2023 22:07:53 +0100 Subject: [PATCH] TypeAnnot --- flap/src/hopix/hopixTypechecker.ml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flap/src/hopix/hopixTypechecker.ml b/flap/src/hopix/hopixTypechecker.ml index 74b98c8..38c7437 100644 --- a/flap/src/hopix/hopixTypechecker.ml +++ b/flap/src/hopix/hopixTypechecker.ml @@ -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