HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.17k stars 654 forks source link

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

Closed issuesbot closed 11 years ago

issuesbot commented 11 years ago

[Google Issue #147 : https://code.google.com/p/haxe/issues/detail?id=147] by pimmhoge...@gmail.com, at 25/06/2010, 17:53:34 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.

issuesbot commented 11 years ago

[comment from ncanna...@gmail.com, published at 23/07/2010, 19:01:35]

issuesbot commented 11 years ago

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