From 3ee85d77663fce5e6a29efa50f63983456e447cf Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 28 Nov 2023 01:59:55 +0100 Subject: [PATCH] fix --- flap/src/hopix/hopixTypechecker.ml | 35 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/flap/src/hopix/hopixTypechecker.ml b/flap/src/hopix/hopixTypechecker.ml index e12389b..bec91ab 100644 --- a/flap/src/hopix/hopixTypechecker.ml +++ b/flap/src/hopix/hopixTypechecker.ml @@ -67,18 +67,21 @@ let rec synth_expression : HopixTypes.typing_environment -> HopixAST.expression Position.located -> HopixTypes.aty = - fun env Position.{ value = e; position = pos } -> function - | Literal l -> type_of_literal l.value - | Variable(id,tlist) -> failwith "Students! This is your job! Variable" - | Tagged(cons,_,[]) -> HopixTypes.hbool (*Pas sûr, j'ai regardé comme dans hopixInterpreter au début*) - | Apply(a,b) -> failwith "Students! This is your job! Apply" - | Record(field,tliste) -> failwith "Students! This is your job! Record" - | Fun(_) -> failwith "Students! This is your job! Fun synth" (* TODO : ici on ne peut pas synthesisé. cf Cours*) - | TypeAnnotation(expr,t) -> failwith "Students! This is your job! TypeAnnotation" + fun env Position.{ value = e; position = pos } -> + match e with + | Literal l -> type_of_literal l.value + | Variable (id, tlist) -> failwith "Students! This is your job! Variable" + | Tagged (cons, _, []) -> + HopixTypes.hbool (*Pas sûr, j'ai regardé comme dans hopixInterpreter au début*) + | Apply (a, b) -> failwith "Students! This is your job! Apply" + | Record (field, tliste) -> failwith "Students! This is your job! Record" + | Fun _ -> + failwith "Students! This is your job! Fun synth" + (* TODO : ici on ne peut pas synthesisé. cf Cours*) + | TypeAnnotation (expr, t) -> failwith "Students! This is your job! TypeAnnotation" - and type_of_literal l = - match l with + match l with | LInt _ -> HopixTypes.hint | LChar _ -> HopixTypes.hchar | LString _ -> HopixTypes.hstring @@ -87,16 +90,16 @@ and check_expression : HopixTypes.typing_environment -> HopixAST.expression Position.located -> HopixTypes.aty -> unit = - fun env (Position.{ value = e; position = pos } as exp) expected -> function - | Fun df -> failwith "Students! This is your job! Fun check" - - + 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" and check_value_definition : HopixTypes.typing_environment -> HopixAST.value_definition -> HopixTypes.typing_environment - = -fun env -> function + = + fun env -> function | SimpleValue (id, Some ty, ex) -> failwith "Students! This is your job! (check_value_definition | SimpleValue)" | RecFunctions _ ->