waneck / testrepo

0 stars 0 forks source link

Issue 147 - Unexpected value returned with inline function (the "phive" bug) - haxe #147

Closed waneck closed 11 years ago

waneck commented 11 years ago

[Google Issue #147 : http://code.google.com/haxe/issues/detail?id=147] by pimmhoge...@gmail.com, at 2010-06-25T17:53:34.000Z The following code traces "3 + 2 = phive", though I'd expect "null":

class Main { public static function main():Void { trace(returnNothing()); } private static inline function returnNothing():Void { "3 + 2 = phive"; } }

This happens on AVM2 and JS, so I assume that it affects all targets.

A workaround is not inlining the function:

class Main { public static function main():Void { trace(returnNothing()); } private static function returnNothing():Void { "3 + 2 = phive"; } }

An other one is adding "null" to the function body:

class Main { public static function main():Void { trace(returnNothing()); } private static function returnNothing():Void { "3 + 2 = phive"; null; } }

Not a high priority issue.

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2010-07-23T19:01:35.000Z]

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2010-12-17T13:56:07.000Z] since inlining inline the function body, this is not an invalid side effect until some practical example shows otherwise