Given:
var wasCalled as Boolean = false; class C { function initialize(logger as Logger) { logger.debug("This should appear"); wasCalled = true; } } (:test) function test(logger as Logger) as Boolean { new C(logger); return wasCalled; }
The code compiles with no warnings or errors with strict type checking enabled, but the test fails. If I change it to "var c = new C(logger);" instead, it passes.
It looks like the compiler completely ignores the "new C". I get the same behavior with every recent sdk, including 4.1.5, 4.1.6 and 4.2.0-beta (and with the last two, at any optimization level).
EDIT: There's more strange behavior. If I add a public foo() method to C, and a public x as Number:
(new C(logger)).foo(); // works as expected. A C is constructed, and foo is called
(new C(logger)).x; // compiles, but C is not constructed
(new C(logger)).x++; // syntax error
++(new C(logger)).x; // syntax error
(new C(logger)).x = 42; // syntax error
EDIT2: Sorry, too many moving parts.
It turns out that (new C(logger)).x does construct a C in 4.1.5, but doesn't in 4.1.6 or 4.2.0-beta (unless you compile at -O0)