My favorites | Sign in
Project Home Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 95: inconsistent return value
1 person starred this issue and may be notified of changes. Back to list
Status:  WontFix
Owner:  ----
Closed:  Jan 2011


 
Reported by michaelbaczynski@gmail.com, Jan 22, 2011
compile the source below using latest haXe/hxcpp version from svn.
f.foo1() and f.foo2() should both trace out null. works if inline keyword is removed

class Main
{
    public static function main()
    {
        var f = new Foo<Int>();
        
        trace(f.foo1()); //output: null
        trace(f.foo2()); //output: 0
    }
}

class Foo<T>
{
    var _null:T;
    
    public function new()
    {
        _null = null;
    }
    
    inline public function foo1():T
    {
        return _null;
    }
    
    inline public function foo2():T
    {
        var a = 0;
        return _null;
    }
}
Jan 22, 2011
Project Member #2 gameh...@gmail.com
This is actually correct because the function returns a Int. If flash + cpp, when returning null, the best you can do is 0.  This allows the target to use very efficient code (ie registers) to hold the values, rather than have to have (if value == null then something else normal processing).  To fix the problem, try f = new Foo< Null<Int> >(), which will allow nulls or Ints.
Status: WontFix

Powered by Google Project Hosting