2
0
Эх сурвалжийг харах

minor bugfix when inlining a single new with a type restriction

Nicolas Cannasse 14 жил өмнө
parent
commit
ecfe2997f5
1 өөрчлөгдсөн 8 нэмэгдсэн , 2 устгасан
  1. 8 2
      optimizer.ml

+ 8 - 2
optimizer.ml

@@ -172,9 +172,15 @@ let type_inline ctx cf f ethis params tret p =
 	if Common.defined ctx.com "js" && (init <> None || !has_vars) then
 	if Common.defined ctx.com "js" && (init <> None || !has_vars) then
 		None
 		None
 	else
 	else
+		let wrap e =
+			match e.eexpr with
+			(* we can't mute the type of a TNew because it will be used later to get parameters *)
+			| TNew _ -> mk (TParenthesis e) tret e.epos
+			| _ -> { e with etype = tret }
+		in
 		let e = (match e.eexpr, init with
 		let e = (match e.eexpr, init with
-			| TBlock [e] , None -> { e with etype = tret; }
-			| _ , None -> { e with etype = tret; }
+			| TBlock [e] , None -> wrap e
+			| _ , None -> wrap e
 			| TBlock l, Some init -> mk (TBlock (init :: l)) tret e.epos
 			| TBlock l, Some init -> mk (TBlock (init :: l)) tret e.epos
 			| _, Some init -> mk (TBlock [init;e]) tret e.epos
 			| _, Some init -> mk (TBlock [init;e]) tret e.epos
 		) in
 		) in