diff --git a/src/passes/10-interpreter/interpreter.ml b/src/passes/10-interpreter/interpreter.ml index 949a832b1..85c15c6fb 100644 --- a/src/passes/10-interpreter/interpreter.ml +++ b/src/passes/10-interpreter/interpreter.ml @@ -342,7 +342,8 @@ and eval : Ast_typed.expression -> env -> value result let {hd;tl;body;tv=_} = cases.match_cons in let env' = Env.extend (Env.extend env (hd,head)) (tl, V_List tail) in eval body env' - | Match_variant {cases=[{constructor=Constructor "true";body=match_true};{constructor=Constructor "false"; body=match_false}];_}, V_Ct (C_bool b) -> + | Match_variant {cases=[{constructor=Constructor t;body=match_true};{constructor=Constructor f; body=match_false}];_}, V_Ct (C_bool b) + when String.equal t "true" && String.equal f "false" -> if b then eval match_true env else eval match_false env | Match_variant {cases ; tv=_} , V_Construct (matched_c , proj) -> diff --git a/src/passes/10-transpiler/transpiler.ml b/src/passes/10-transpiler/transpiler.ml index 4bf78a0c9..a7ca1f555 100644 --- a/src/passes/10-transpiler/transpiler.ml +++ b/src/passes/10-transpiler/transpiler.ml @@ -580,7 +580,8 @@ and transpile_annotated_expression (ae:AST.expression) : expression result = in return @@ E_if_cons (expr' , nil , cons) ) - | Match_variant {cases=[{constructor=Constructor "true";body=match_true};{constructor=Constructor "false";body=match_false}];_} -> + | Match_variant {cases=[{constructor=Constructor t;body=match_true};{constructor=Constructor f;body=match_false}];_} + when String.equal t "true" && String.equal f "false" -> let%bind (t , f) = bind_map_pair (transpile_annotated_expression) (match_true, match_false) in return @@ E_if_bool (expr', t, f) | Match_variant {cases ; tv} -> ( @@ -703,7 +704,8 @@ and transpile_recursive {fun_name; fun_type; lambda} = in return @@ E_if_cons (expr , nil , cons) ) - | Match_variant {cases=[{constructor=Constructor "true";body=match_true};{constructor=Constructor "false";body=match_false}];_} -> + | Match_variant {cases=[{constructor=Constructor t;body=match_true};{constructor=Constructor f;body=match_false}];_} + when String.equal t "true" && String.equal f "false" -> let%bind (t , f) = bind_map_pair (replace_callback fun_name loop_type shadowed) (match_true, match_false) in return @@ E_if_bool (expr, t, f) | Match_variant {cases;tv} -> (