Browse Source

consider field inits while inlining constructors (closes #2336)

Simon Krajewski 12 years ago
parent
commit
47932889c8
1 changed files with 5 additions and 0 deletions
  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