Mono + Anonymous delegates

Tried to get my code to compile but i got this error:

cyrusn@Foo ~> /opt/local/bin/gmcs foo.cs
Mono C# Compiler for Generics
System.NullReferenceException: Object reference not set to an instance of an object
in <0x14828> Mono.CSharp.CSharpParser:yyparse (Mono.CSharp.yyParser.yyInput)
in <0x000b4> Mono.CSharp.CSharpParser:parse ()

foo.cs(30) error CS8025: Parsing error
Compilation failed: 1 error(s), 0 warnings

Not encouraged by the exception, but it is experimental code in a piece of beta software. (and my own code throws exceptions, so who am i to talk 🙂 ). However, it did give me the line number (yaaay). I went there and saw that it was this bit of code:

    public Creator> Drop(int elements) {
        return delegate { return this; };

I'm wondering if it's anonymous delegates. I'll see if i can figure out what's going on and maybe how to work around it. I also filed this this bug to help out the mono developers.

Comments (7)

  1. arhra says:

    anonymous delegates aren’t fully implemented yet, afaik – last i heard, miguel was working on them with a seperate branch, and it hasn’t been merged back into the main codebase yet. The last time he mentioned it on his blog ( was in the middle of April, and i don’t recall seeing anything significant on the subject on the mailing list

  2. Miguel de Icaza says:

    Anonymous methods are not part of the main tree at this point, I will correct the error above (I should not have turned v2 features on by default yet).

    As for the generics compiler: you must use the `gmcs’ program, not `mcs’.

  3. Thanks for the info Arhra/Miguel. From the mono roadmap it looks like these feature are expected late 2004. Is that correct? If so, i’m looking forward to seeing them become available so quickly!

Skip to main content