From 45bbd6a0dd891b992ba2dbe37a5d5a4c80825271 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 5 Dec 2023 04:17:53 +0100 Subject: [PATCH] synth_ifthenelse --- flap/src/hopix/hopixTypechecker.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/flap/src/hopix/hopixTypechecker.ml b/flap/src/hopix/hopixTypechecker.ml index 6cd68ff..694c74f 100644 --- a/flap/src/hopix/hopixTypechecker.ml +++ b/flap/src/hopix/hopixTypechecker.ml @@ -216,7 +216,15 @@ and synth_ifthenelse : HopixTypes.typing_environment -> expression Position.located -> expression Position.located -> expression Position.located -> HopixTypes.aty = - fun tenv ecase eif eelse -> failwith "Students! This is your job! (synth_ifthenelse)" + fun tenv ecase eif eelse -> + (* Pas testé !! *) + let ecasety = synth_expression tenv ecase in + check_equal_types ecase.position ~expected:ecasety ~given:HopixTypes.hbool; + let eifty = synth_expression tenv eif in + check_equal_types eif.position ~expected:eifty ~given:HopixTypes.hunit; + let eelsety = synth_expression tenv eelse in + check_equal_types eelse.position ~expected:eelsety ~given:HopixTypes.hunit; + HopixTypes.hunit and synth_while : HopixTypes.typing_environment -> expression Position.located