Forums

Error when compiling multiple files

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Error when compiling multiple files

Postby Gameday » Sun May 09, 2010 11:47 am

Let's say I have these two classes:

x.cobra
Code: Select all
class X
   get a from var = ""


and

e.cobra
Code: Select all
class T
   def main is shared
      x = X()
      puts x.a


When I run them, like cobra -c x.cobra e.cobra, I receive this error:
Code: Select all
e.cobra(4): error: e.cobra(4,8): error: Expecting EOL, but got "x" (ID) instead.
Compilation failed - 1 error, 0 warnings


If I run them separately, after adding a main method to the first file, they work. What am I doing wrong?
Gameday
 
Posts: 27

Re: Error when compiling multiple files

Postby Charles » Sun May 09, 2010 5:41 pm

I get that error too until I change "puts" to "print". They probably worked when you compiled separately because you commented out the "puts" line to do so.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Error when compiling multiple files

Postby Charles » Sun May 09, 2010 6:49 pm

I enhanced the compiler to suggest "print" when it sees "puts" in this circumstance. It now reads:
Code: Select all
error: Expecting EOL, but got "x" (ID) instead. Try "print" instead of "puts".

There are already suggestions for various bits of Python, C# and Visual Basic that have direct corollaries in Cobra, but different names, so this type of enhancement fits in well.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Error when compiling multiple files

Postby Gameday » Sun May 09, 2010 10:24 pm

Oh my god!
I didn't even notice I had "puts" there. I'm so sorry, it's just I've been using Ruby for such a long time, it's kind of like second nature. :oops:
Gameday
 
Posts: 27

Re: Error when compiling multiple files

Postby Charles » Sun May 09, 2010 10:26 pm

No apology necessary. Other Ruby users will have the same experience so this will lead to a useful improvement to the compiler which help people out.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Error when compiling multiple files

Postby CodexArcanum » Mon May 10, 2010 9:03 pm

The cobra compiler's suggestions are pretty amazingly helpful, works out well since there's not Intellisense/Autocomplete for it yet. Just today I had something about foo.width, which doesn't exist, and the compiler suggested that maybe I meant foo.getFooWidth. That was, indeed, the call I needed.
CodexArcanum
 
Posts: 21


Return to Discussion

Who is online

Users browsing this forum: No registered users and 43 guests