From a2c2a3a619ec7cd118d7a00b2037b766b0cd701c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pasteur?= Date: Mon, 2 May 2011 15:20:12 +0200 Subject: [PATCH] Fixed typing of if then else First try as T * at r * T -> at r and then as T * T * at r --- compiler/heptagon/analysis/linear_typing.ml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/heptagon/analysis/linear_typing.ml b/compiler/heptagon/analysis/linear_typing.ml index cca6f97..8a10786 100644 --- a/compiler/heptagon/analysis/linear_typing.ml +++ b/compiler/heptagon/analysis/linear_typing.ml @@ -544,12 +544,16 @@ and expect_app env expected_lin op e_list = match op with | Eifthenelse -> let e1, e2, e3 = assert_3 e_list in let env = safe_expect env Ltop e1 in - let c2 = collect_exp env e2 in - let c3 = collect_exp env e3 in - let l2, l3 = assert_2 (unify_collect [c2;c3] [expected_lin] [e2;e3]) in - let env = safe_expect env l2 e2 in - let env = safe_expect env l3 e3 in - expected_lin, env + (try + let l, env = expect env expected_lin e2 in + let _, env = expect env (not_linear_for_exp e3) e3 in + l, env + with + UnifyFailed -> + let l, env = expect env expected_lin e3 in + let _, env = expect env (not_linear_for_exp e2) e2 in + l, env + ) | Efield_update -> let e1, e2 = assert_2 e_list in