Bläddra i källkod

be again a bit more liberal on the things we allow in inline var

Nicolas Cannasse 13 år sedan
förälder
incheckning
5bed8e3a09
1 ändrade filer med 8 tillägg och 4 borttagningar
  1. 8 4
      typeload.ml

+ 8 - 4
typeload.ml

@@ -923,10 +923,14 @@ let init_class ctx c p herits fields =
 							let e = type_static_var ctx t e p in
 							let e = (if inline then 
 								let e = ctx.g.do_optimize ctx e in
-								(match e.eexpr with
-								| TConst _ -> ()
-								| TBinop ((OpAdd|OpSub|OpMult|OpDiv|OpMod),{ eexpr = TConst (TInt _|TString _|TFloat _) },{ eexpr = TConst (TInt _|TString _|TFloat _) }) -> ()
-								| _ -> display_error ctx "Inline variable must be a constant value" p);
+								let rec is_const e =
+									match e.eexpr with
+									| TConst _ -> true
+									| TBinop ((OpAdd|OpSub|OpMult|OpDiv|OpMod),e1,e2) -> is_const e1 && is_const e2
+									| TParenthesis e -> is_const e
+									| _ -> false
+								in
+								if not (is_const e) then display_error ctx "Inline variable must be a constant value" p;
 								e
 							else e) in
 							cf.cf_expr <- Some e;