| Issue 168: | Interface with optional arguments fail | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. Create this interface ISample.hx :
interface ISample {
function aFunction( i : Int, ?a : String ) : String;
}
2. Create this class Sample.hx :
class Sample implements ISample {
public
function aFunction ( i : Int, ?a : String )
{
return ' ';
}
}
3. Create a main class Main.hx :
class Main {
var s : Sample;
}
4. Try to build
What is the expected output? What do you see instead?
Expected normal building.
You will get something like:
g++ -Iinclude -c -fvisibility=hidden -O2 -fpic -fPIC -DHX_LINUX -DHXCPP_SET_PROP -m32 -I/home/raul/projectos/haxe/haxelib/hxcpp/2,09//include -frtti -o hxcpp.h.gch /home/raul/projectos/haxe/haxelib/hxcpp/2,09//include/hxcpp.h
g++ -I. -Iinclude -c -fvisibility=hidden -O2 -fpic -fPIC -DHX_LINUX -DHXCPP_SET_PROP -m32 -I/home/raul/projectos/haxe/haxelib/hxcpp/2,09//include -x c++ -frtti ./src/Sample.cpp -oobj/linux//src/Sample.o
In file included from ./src/Sample.cpp:4:0:
include/ISample.h: En la función miembro ‘String ISample_delegate_<IMPL>::aFunction(int, hx::Null<String>) [con IMPL = Sample_obj]’:
./src/Sample.cpp:93:1: instanciado desde aquí
include/ISample.h:33:3: error: no se encontró una función coincidente para la llamada a ‘Sample_obj::aFunction(int&, hx::Null<String>&)’
include/ISample.h:33:3: nota: el candidato es:
./src/Sample.cpp:33:10: nota: virtual String Sample_obj::aFunction(int, String)
./src/Sample.cpp:33:10: nota: no hay una conversión conocida para el argumento 2 de ‘hx::Null<String>’ a ‘String’
Called from ? line 1
Called from BuildTool.hx line 1246
Called from BuildTool.hx line 554
Called from a C function
Called from BuildTool.hx line 591
Called from BuildTool.hx line 710
Called from BuildTool.hx line 746
Called from BuildTool.hx line 200
Uncaught exception - Error : 256 - build cancelled
What version of the product are you using? On what operating system?
Latest haxe (2.09) Latest hxcpp (2.09)
Please provide any additional information below.
Apr 24, 2012
#1
raul.fer...@gmail.com
Apr 24, 2012
Hi,
Looks like 'String' slipped though the net. It is an unusual one because it is not an object, and yet it has its own internal null implementation.
The real fix it to patch the haxe compiler. However, in the meantime, you could try patching HXCPP/include/hxString.h by adding the line to the top of the String class:
String(hx::Null<String> inRHS) : __s(inRHS.value.__s), length(inRHS.value.length) { }
Apr 24, 2012
Work around works :D, Many thanks!
Apr 27, 2012
gday, will this patch be in future hxcpp releases? Or should I change local code to ?foo:Null<String> instead of ?foo:String
May 9, 2012
I have put this fix into SVN for now. I will think about a tiny performance improvement for the compiler later.
Status:
Fixed
|