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 135: compilation error when assigning value to function typed field via interface
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Sep 2011


 
Reported by alexborm...@gmail.com, Sep 8, 2011
To reproduce try to compile the following code:

-------------------------------------------------------------------------

package ; 

class Main 
{ 
        static function main() 
        { 
                new Main(); 
        } 
        
        function new() 
        { 
                var i:MyInterface = new MyClass(); 
                i.handler = handle; 
                i.handler(); 
        } 
        function handle():Void 
        { 
                trace('success'); 
        } 
} 

interface MyInterface 
{ 
        var handler:Void->Void; 
} 

class MyClass implements MyInterface 
{ 
        public function new() { } 
        public var handler:Void->Void; 
} 


-------------------------------------------------------------------------

This code is compiled into swf and works fine, but compilation error occures when targeting cpp. Error output is following:

-------------------------------------------------------------------------

./src/Main.cpp(22) : error C2659: '=' : function as left operand 
D:\Projects\_temporary\hxcpp-test\bin\include\MyInterface.h(33) : error C2664: 'null::null(const null &)' : cannot convert parameter 1 from 'Dynamic' to 'const null &' 
        Reason: cannot convert from 'Dynamic' to 'const null' 
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 
        D:\Projects\_temporary\hxcpp-test\bin\include\MyInterface.h(33) : while compiling class template member function 'Void MyInterface_delegate_<IMPL>::handler(void)' 
        with 
        [ 
            IMPL=MyClass_obj 
        ] 
        D:\Projects\_temporary\hxcpp-test\bin\include\MyClass.h(31) : see reference to class template instantiation 'MyInterface_delegate_<IMPL>' being compiled 
        with 
        [ 
            IMPL=MyClass_obj 
        ] 
Called from ? line 1 
Called from BuildTool.hx line 1100 
Called from BuildTool.hx line 501 
Called from BuildTool.hx line 538 
Called from BuildTool.hx line 657 
Called from BuildTool.hx line 729 
Uncaught exception - Error in building thread 
D:\Projects\_temporary\hxcpp-test\bin\include\MyInterface.h(33) : error C2664: 'null::null(const null &)' : cannot convert parameter 1 from 'Dynamic' to 'const null &' 
        Reason: cannot convert from 'Dynamic' to 'const null' 
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 
        D:\Projects\_temporary\hxcpp-test\bin\include\MyInterface.h(33) : while compiling class template member function 'Void MyInterface_delegate_<IMPL>::handler(void)' 
        with 
        [ 
            IMPL=MyClass_obj 
        ] 
        D:\Projects\_temporary\hxcpp-test\bin\include\MyClass.h(31) : see reference to class template instantiation 'MyInterface_delegate_<IMPL>' being compiled 
        with 
        [ 
            IMPL=MyClass_obj 
        ] 
Error : Build failed 
Build halted with errors (haxe.exe). 

-------------------------------------------------------------------------

The latest trunk version of hxcpp is used.
Sep 14, 2011
Project Member #1 gameh...@gmail.com
Should be fixed on haxe SVN now.
Status: Fixed

Powered by Google Project Hosting