Error: Illegal Type Expression - HELP
Monkey Forums/Monkey Beginners/Error: Illegal Type Expression - HELP
| ||
Ok, so I did my fair bit in Blitzmax, and now I decided to switch over to Monkey X. I had some problem figuring out the difference between blitxmax's import and monkey's import, but I now think that is sorted out. My problem is after importing my GUI I'm building, nothing is detected correctly! Take a look: -- Code -- Strict Import CGUI ' CGUI is 'CGUI.monkey' and is located in the same folder Class Game Extends App Field element:elements Method OnCreate() ' <- The error: Illegal Type expression points here element = cgui_CreateElement( 4, 4, 640, 480 ) End Method End Class Function main() New Game End Function -- End of Code -- The CGUI.monkey looks like this: -- Code -- #Rem Module: Ced's Graphical User Interface ( CGUI ) Author: Cedrik Duboid ( Garvorik ) Description: The aim of this module is to offer quick and customizable GUI elements for fast yet great interfaces. #End Import mojo Import constants Import interfaces Import classes Import elements Global CGUIElements:List<elements> = New List<elements> Function cgui_CreateElement:elements( x:Float, y:Float, width:Float, height:Float ) Return New elements( x, y, width, height ) End Function -- End of code -- So the problem, like I said, is that the debugger won't allow my 'Method OnCreate()'. I don't understand at all, so help would be appreciated! - Garvorik |
| ||
In Strict mode, all types must be declared explicitly. This includes functions and methods -- you need to specify a return type. The return type in this case comes from App -- it's Int. Therefore, make sure the following methods return Int: Main() OnCreate() OnRender() OnUpdate() Furthermore, in Strict mode all non-void return types must return a value, which is why you'll commonly see strict methods ending with "Return 0". |
| ||
You'll see "Illegal type error" a lot in this situation! It would be nice if at some stage such cases were detected and replaced with "Function must return a value". |
| ||
Thanks a lot for your answers. I see, that makes sense, and I agree with Gerry Quinn, the compiler should notice the developper of that specific error. Again, thanks a lot :D |
| ||
Oh, yeah, and by the way, where can I find a list of the equivalent of the bbcodes for this forum? Using something like this: some code here would be really usefull. |
| ||
Oh. Nevermind, seems to work, lol. Could someone point me to a list of available bbcodes? |
| ||
look at the right side of the "Post Reply To Topic" edit field... "Forum Code" will bring you to http://www.monkey-x.com/Community/posts.php?topic=7846#forum-codes-content |
| ||
Ah thanks! Seems I was completely blind about that.... O.O |