Forums

Internal Error with Named Arguments

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

Internal Error with Named Arguments

Postby oahmad04 » Mon Apr 21, 2014 5:34 pm

I'm pretty sure this one's not my fault...

If I have the following file:
@args target:lib

namespace Bad

class Thing

cue init(name)
base.init
print name

class Other inherits Thing

cue init
base.init(name = 'fries')


I get the following error:
Code: Select all
error: COBRA INTERNAL ERROR / NullReferenceException / Object reference not set to an instance of an object


Cobra svn: 3116
Mac OS X 10.9.2

Thanks
oahmad04
 
Posts: 19
Location: Canada

Re: Internal Error with Named Arguments

Postby hopscc » Tue Apr 22, 2014 2:14 am

Youre not setting default args here and I dont believe cobra has named arg assignment

This is attempting to call a noarg ctor and set a property called (.name) neither of which exist (assignment in call not in declaration)
( the error message could be better)

This instead for default named args:

@args target:lib

namespace NotSoBad

class Thing

cue init(name)
base.init
print name

class Other inherits Thing

cue init(name = 'fries')
base.init(name)
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: Internal Error with Named Arguments

Postby hopscc » Tue Apr 22, 2014 4:26 am

and I dont believe cobra has named arg assignment


oops it does :oops:
so what you wrote should work....
The assignment expression is missing a couple of the binding phases for some reason...
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: Internal Error with Named Arguments

Postby hopscc » Wed Apr 23, 2014 1:29 am

Well I've found the cause of this - seems the tree code change supporting all this ( keyword and default args) had a line from the patch commented out
(Expr.cobra line 827).

reasserting that gives a compile pass but emits a C# compilation error as does trying to do the above purely in C# so looks like this particular combo of named args on initialisers (pass through to ancestors) isnt supported in C# either...

Code: Select all
namespace Bad {
        public class Thing : System.Object {

                public  Thing( object name) : base() {
                        System.Console.WriteLine(name);
                }

        } // class Thing

        public class Other : Bad.Thing {

                public  Other() : base(name="fries") {
                        System.String name = null;
                }

        } // class Other

} // namespace Bad

gives
Code: Select all
620 xx:...src/cobra/Tst/2014> cobra defArgErr.cs
c:\Users\hops\src\cobra\Tst\2014\defArgErr.cs(12): error: The name "name" does not exist in the current context (C#)
Compilation failed - 1 error, 0 warnings
Not running due to errors above.
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron