Beginner error

Monkey Forums/Monkey Programming/Beginner error

Zedronar(Posted 2014) [#1]
Sorry for bothering you with this stupid error, but I've spent the whole night trying to solve this with no luck.

Here's the code:

Function Sum:Int( x:Int,y:Int )
Return x+y
End

Function Main()
Print Sum( 10,20 )
End

Here's the error:

g++ -Wno-free-nonheap-object -I../glfw/include -I../glfw/lib -I../glfw/lib/win32 -I../openal/include -I../stb -c -o ../main.o ../main.cpp
../main.cpp:2736:20: error: expected initializer before 'Variables'
int bb_2_Functions Variables and Types_Sum(int,int);
^
../main.cpp:2738:20: error: expected initializer before 'Variables'
int bb_2_Functions Variables and Types_Sum(int t_x,int t_y){
^
../main.cpp: In function 'int bbMain()':
../main.cpp:2749:17: error: 'bb_2_Functions' was not declared in this scope
bbPrint(String(bb_2_Functions Variables and Types_Sum(10,20)));
^
<builtin>: recipe for target '../main.o' failed
mingw32-make: *** [../main.o] Error 1
TRANS FAILED: Error executing 'mingw32-make CCOPTS="-Wno-free-nonheap-object" OUT="Debug/MonkeyGame"', return code=2
Done.



Any ideas?


Trez(Posted 2014) [#2]
I don't see any error in the code you posted ! unless you have Strict at the top.

Function Sum:Int(x:Int, y:Int)
	Return x + y
End

Function Main()
	Print Sum(10, 20)
End



Gerry Quinn(Posted 2014) [#3]
Works fine for me (using V75, but that's probably not relevant). Have you tried it in HTML5? It looks more like some sort of configuration error than anything in your code.


Zedronar(Posted 2014) [#4]
I've tried with HTML5 as well. In the chrome console says "Uncaught SyntaxError: Unexpected identifier ".

If it's a configuration error (which shouldn't, since I've touched nothing), where should I check?


Trez(Posted 2014) [#5]
Can you compile and run any of the examples that come with Monkey ?


Zedronar(Posted 2014) [#6]
Yeah, the examples work correctly. I have no idea what this might be.


Trez(Posted 2014) [#7]
Do you have Strict at the top of your code ?


Goodlookinguy(Posted 2014) [#8]
What version of Monkey X are you using? It looks like a translation bug, but I think it was fixed already.

Edit: Did your file name contain spaces? That's a surefire way to cause it to not compile.


Zedronar(Posted 2014) [#9]
Solved uninstalling and installing Monkey again.