Преглед на файлове

forbid static inline var when not a constant (after optimization)

Nicolas Cannasse преди 13 години
родител
ревизия
3127030517
променени са 1 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. 9 1
      typeload.ml

+ 9 - 1
typeload.ml

@@ -915,7 +915,15 @@ let init_class ctx c p herits fields =
 							r := (fun() -> t);
 							if ctx.com.verbose then Common.log ctx.com ("Typing " ^ (if ctx.in_macro then "macro " else "") ^ s_type_path c.cl_path ^ "." ^ name);
 							mark_used cf;
-							cf.cf_expr <- Some (type_static_var ctx t e p);
+							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 _ -> ()
+								| _ -> display_error ctx "Inline variable must be a constant value" p);
+								e
+							else e) in
+							cf.cf_expr <- Some e;
 							cf.cf_type <- t;
 						end;
 						t