summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-11-12 20:54:27 +0000
committerAlasdair Armstrong2018-11-12 22:15:39 +0000
commit7a0fba122b781a41de080e365c6d360f41117698 (patch)
tree6d80093258140c2bf3a003776c16e835501ecc82 /src
parent76d5e3227d529f6ef23a822e498b476e9bccae5c (diff)
Infer tuple l-expressions types if all components are inferrable
This fixes another case we often have to patch manually in translated ASL code where a function returns a (result, Constraint)-pair. Also (slightly) improve the error message for when we fail to infer a l-expression, as we are going to hit this case more often now.
Diffstat (limited to 'src')
-rw-r--r--src/type_check.ml5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/type_check.ml b/src/type_check.ml
index 716e6df5..e11505e5 100644
--- a/src/type_check.ml
+++ b/src/type_check.ml
@@ -3105,7 +3105,10 @@ and infer_lexp env (LEXP_aux (lexp_aux, (l, ())) as lexp) =
in
let typq, _, ret_typ, _ = Env.get_accessor rec_id fid env in
annot_lexp_effect (LEXP_field (annot_lexp (LEXP_id v) (mk_id_typ rec_id), fid)) ret_typ weff
- | _ -> typ_error l ("Unhandled l-expression " ^ string_of_lexp lexp)
+ | LEXP_tup lexps ->
+ let inferred_lexps = List.map (infer_lexp env) lexps in
+ annot_lexp (LEXP_tup inferred_lexps) (tuple_typ (List.map lexp_typ_of inferred_lexps))
+ | _ -> typ_error l ("Could not infer the type of " ^ string_of_lexp lexp)
and infer_exp env (E_aux (exp_aux, (l, ())) as exp) =
let annot_exp_effect exp typ eff = E_aux (exp, (l, Some ((env, typ, eff),None))) in