* Always unwrap blocks that return an inline object. Fixes #6324 * Test for issue #6324 * Change analyzer(ignore) into analyzer(no_optimize)
@@ -496,7 +496,7 @@ let inline_constructors ctx e =
loop (el'@acc) el
in
let el, io = loop [] el in
- let el = if unwrap_block then el else [mk (TBlock (List.rev el)) e.etype e.epos] in
+ let el = if unwrap_block || Option.is_some io then el else [mk (TBlock (List.rev el)) e.etype e.epos] in
el, io
| TMeta((Meta.InlineConstructorArgument (_,io_id_start),_,_),e) ->
let old_io_id = !current_io_id in
@@ -0,0 +1,32 @@
+package unit.issues;
+
+class Issue6342 extends unit.Test {
+ @:analyzer(no_optimize)
+ function test() {
+ var t = new A(1);
+ var tmp1 = t.foo().x;
+ eq(1, tmp1);
+ var tmp2 = ({
+ new A(2);
+ }).x;
+ eq(2, tmp2);
+ }
+}
+@:keep
+private class A
+{
+ public var x:Int;
+ public inline function new(x) {
+ this.x = x;
+ public inline function foo() {
+ var tmp = x;
+ return new A(x);