From fe1475a03ef855a5737a5c3d50a4edcb73869cf8 Mon Sep 17 00:00:00 2001 From: Adrien Guatto Date: Tue, 17 Aug 2010 15:04:54 +0200 Subject: [PATCH] Typing fix: type static exp initializing a last. --- compiler/heptagon/analysis/typing.ml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/heptagon/analysis/typing.ml b/compiler/heptagon/analysis/typing.ml index c00e48e..a7276a6 100644 --- a/compiler/heptagon/analysis/typing.ml +++ b/compiler/heptagon/analysis/typing.ml @@ -994,12 +994,17 @@ and build const_env h dec = let var_dec (acc_defined, h) vd = try let ty = check_type const_env vd.v_type in - if Env.mem vd.v_ident h then - error (Ealready_defined(sourcename vd.v_ident)); - let acc_defined = Env.add vd.v_ident ty acc_defined in - let h = Env.add vd.v_ident { ty = ty; last = last vd.v_last } h in - { vd with v_type = ty }, (acc_defined, h) + let last_dec = match vd.v_last with + | Last (Some se) -> Last (Some (expect_static_exp const_env ty se)) + | Var | Last None -> vd.v_last in + + if Env.mem vd.v_ident h then + error (Ealready_defined(sourcename vd.v_ident)); + + let acc_defined = Env.add vd.v_ident ty acc_defined in + let h = Env.add vd.v_ident { ty = ty; last = last vd.v_last } h in + { vd with v_last = last_dec; v_type = ty }, (acc_defined, h) with TypingError(kind) -> message vd.v_loc kind in