Browse Source

Display warning when constructor inlining is cancelled because of the use of an uninitialized field.

Mario Carbajal 4 years ago
parent
commit
0d4373f4e3
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/optimization/inlineConstructors.ml

+ 4 - 1
src/optimization/inlineConstructors.ml

@@ -316,7 +316,10 @@ let inline_constructors ctx original_e =
 						let iv_is_const iv = match iv.iv_kind with IVKField(_,_,Some(_)) -> true | _ -> false in
 						let iv_is_const iv = match iv.iv_kind with IVKField(_,_,Some(_)) -> true | _ -> false in
 						if is_lvalue && iv_is_const fiv then raise Not_found;
 						if is_lvalue && iv_is_const fiv then raise Not_found;
 						if fiv.iv_closed then raise Not_found;
 						if fiv.iv_closed then raise Not_found;
-						if not is_lvalue && fiv.iv_state == IVSUnassigned then raise Not_found;
+						if not is_lvalue && fiv.iv_state == IVSUnassigned then (
+							ctx.com.warning ("Constructor inlining cancelled because of use of uninitialized member field " ^ fname) ethis.epos;
+							raise Not_found
+						);
 						if not captured then cancel_iv fiv efield.epos;
 						if not captured then cancel_iv fiv efield.epos;
 						IOFInlineVar(fiv)
 						IOFInlineVar(fiv)
 					with Not_found ->
 					with Not_found ->