Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ compiler build error when Interface implementation is wrong #488

Open
D-a-n-i-l-o opened this issue Sep 3, 2019 · 2 comments
Open

Comments

@D-a-n-i-l-o
Copy link
Contributor

D-a-n-i-l-o commented Sep 3, 2019

In the following code the implementation of 'MyMethod:String' in class 'Test' does not match the signature of 'MyMethod:Bool" in the interface 'MyInterface':

Interface MyInterface
    Method MyMethod:Bool()
End

Class Test Implements MyInterface
    Method MyMethod:String()
        Return "string"
    End
End

Function Main()
    New Test
End

I get a c++ build error:

Parsing...
Semanting...
Translating...
Compiling...
Build error: System command failed:

g++ -c -std=c++14 -mmacosx-version-min=10.9 -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality -O3 -DNDEBUG -I"/Users/danilo/Monkey/monkey2/modules/" -I"/Users/danilo/Monkey/monkey2/modules/monkey/native" -I"/Users/danilo/Monkey/monkey2/tmp/" -DNDEBUG=1 -DBB_THREADS=1 -I"/Users/danilo/Monkey/monkey2/tmp/untitled10.buildv1.1.15/macos_release_mx/build/" -MMD -MF"/Users/danilo/Monkey/monkey2/tmp/untitled10.buildv1.1.15/macos_release_mx/build/r5b58089e.cpp_r.deps" -o "/Users/danilo/Monkey/monkey2/tmp/untitled10.buildv1.1.15/macos_release_mx/build/r5b58089e.cpp_r.o" "/Users/danilo/Monkey/monkey2/tmp/untitled10.buildv1.1.15/macos_release_mx/include/_r.cpp"

In file included from /Users/danilo/Monkey/monkey2/tmp/untitled10.buildv1.1.15/macos_release_mx/include/_r.cpp:9:
/Users/danilo/Monkey/monkey2/tmp/untitled10.buildv1.1.15/macos_release_mx/include/untitled10_untitled10.h:32:12: error: virtual function 'm_MyMethod' has a different return type ('bbString') than the function it overrides (which has return type 'bbBool' (aka 'bool'))
  bbString m_MyMethod();
  ~~~~~~~~ ^
/Users/danilo/Monkey/monkey2/tmp/untitled10.buildv1.1.15/macos_release_mx/include/untitled10_untitled10.h:21:18: note: overridden virtual function is here
  virtual bbBool m_MyMethod()=0;
          ~~~~~~ ^
1 error generated.


***** Fatal mx2cc error *****

Internal mx2cc build error

It always happens when the return type does not match the interface exactly:

Interface MyInterface
    Method MyMethod:Int()
End

Class Test Implements MyInterface
    Method MyMethod:UInt()
        Return True
    End
End

Function Main()
    New Test
End
@scurty-labs
Copy link

I replaced both types with 'MyMethod:Variant()' compiled fine. I'm assuming C++ doesn't allow this circumstance as I get the same error on Linux as well. Not sure if this is a proper solution.

@D-a-n-i-l-o
Copy link
Contributor Author

Monkey2 should recognize the wrong signature, @scurty-labs.

The Interface-Method "MyMethod:Bool()" is missing from the Class, so Monkey2 could catch that mistake and throw an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants