浏览代码

consider field inits while inlining constructors (closes #2336)

Simon Krajewski 12 年之前
父节点
当前提交
47932889c8
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      optimizer.ml

+ 5 - 0
optimizer.ml

@@ -1012,6 +1012,11 @@ let inline_constructors ctx e =
 					| None -> ()
 					| Some ecst ->
 						let assigns = ref [] in
+						(* add field inits here because the filter has not run yet (issue #2336) *)
+						List.iter (fun cf -> match cf.cf_kind,cf.cf_expr with
+							| Var _,Some e -> assigns := (cf.cf_name,e,cf.cf_type) :: !assigns
+							| _ -> ()
+						) c.cl_ordered_fields;
 						(* make sure we only have v.field = expr calls *)
 						let rec get_assigns e =
 							match e.eexpr with