Page 1 of 1

Incorrect method invocation doesn't get reported (cobra bug)

PostPosted: Fri Jun 21, 2013 11:29 pm
by Chasm
So, here I am again, this time with a very small program that nicely demonstrates the problem:

System: Win 7 x86-64
IDE: Xamarin
Cobra: Latest (0.9.4)

Code: Select all
class Program

   def main
      variable as int
      streamReader = StreamReader("Something.txt")
      streamReader.getType(variable,


As you can see, the getType invocation is incorrect, but the compiler completely fails to report any problem.
The only error I get is: 'Error: error: COBRA INTERNAL ERROR / NullReferenceException / Object reference not set to an instance of an object.
(Error2)
'

Do I post bugs and weirdness that I find here, or is there some bugzilla-like place you guys have?

Hope this helps

Re: Incorrect method invocation doesn't get reported (cobra

PostPosted: Sat Jun 22, 2013 2:13 am
by hopscc
Thx for that, small simple tests cases always help.

Theres a trac ticket report system at http://cobra-language.com/trac/cobra/report.
Choose a report and look at the tickets
You can add/edit/augment tickets if you login to the trac side of things ( use same login as the forum) which can be done off any of the trac pages.

Usually its 'better' to post a bug query/report/weirdness Question on the forum to see if theres any discussion/followup needed...
("thats not a bug its a feature - and heres why :) "
Once a clear issue and test case is available open a specific ticket and (perhaps) reference any forum discussion..
But whatever you find preferable...

If you hit something that generates a cobra compiler 'COBRA INTERNAL ERROR') just open a ticket - no discussion required (unless you want one)

I've got a fix for this specific situation.... I'll open a ticket and put a patch on it

Re: Incorrect method invocation doesn't get reported (cobra

PostPosted: Sat Jun 22, 2013 4:44 am
by Chasm
Got it - Cobra Error -> Ticket, other things -> forum first.

You guys are doing a great job. :)

Re: Incorrect method invocation doesn't get reported (cobra

PostPosted: Sat Jun 22, 2013 8:01 am
by hopscc
Opinions vary :)

Bug logged on ticket:334

Re: Incorrect method invocation doesn't get reported (cobra

PostPosted: Sun Jun 23, 2013 4:30 am
by hopscc
patch on ticket.

Re: Incorrect method invocation doesn't get reported (cobra

PostPosted: Sun Jun 23, 2013 12:25 pm
by Charles
I think you forgot to upload the patch on that ticket.

Re: Incorrect method invocation doesn't get reported (cobra

PostPosted: Sun Jun 23, 2013 11:57 pm
by hopscc
Oops :oops:
Darn those pesky kids.
Try again.

Re: Incorrect method invocation doesn't get reported (cobra

PostPosted: Thu Jun 27, 2013 5:46 pm
by Charles
Fixed.

I took a different approach than the patch; one that I hope will fix this across all situations. I made the following changes:

The tokenizer always produces an EOF at the end of the token stream. In fact, calling .nextToken will continue to produce EOF's and the method can no longer return nil.

Tokenizer.allTokens returns a finite list guaranteed to at least have an EOF token at the end.

There is an IToken.isEOF boolean property that can be queried.

Parser.peek and .grab can no longer return nil, but will instead return EOF. Consequently, there is no need to check for nil tokens (in fact, this will produce a warning that they can never be nil).

Those changes all lead to this:

As many of the token examinations in CobraParser are based on .which, it naturally falls out that a .which of "EOF" will not match what various parsing methods are looking for, causing them to skip to other parsing logic or to complain about what was expected.

It's a (minor) variation on the Null Object Pattern.