| Issue 95: | inconsistent return value | |
| 1 person starred this issue and may be notified of changes. | Back to list |
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
#1
michaelbaczynski@gmail.com
Jan 22, 2011
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
|