Bug 14962 - Error CS0584: Internal compiler error: Object reference not set to an instance of an object (CS0584) with default values and named arguments
Summary: Error CS0584: Internal compiler error: Object reference not set to an instanc...
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2013-09-24 15:50 UTC by Kirk Woll
Modified: 2013-09-25 04:54 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Kirk Woll 2013-09-24 15:50:06 UTC
Consider the following program:

    [Register ("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
            M(z: 1, whatever: 0);
            return true;
        private void M(int x = 0, int y = 0, int z = 0){}

Attempting to compile this will result in the error:

> Error CS0584: Internal compiler error: Object reference not set to an instance of an object (CS0584)

Notice that the second argument to M is invalid ("whatever").  However, I would expect an error message indicating that rather than the compiler crash.  Interestingly if you change the order of the arguments to:

    M(whatever: 0, z: 1);

Then the compiler still crashes, but also provides the useful message:

> Error CS1739: The best overloaded method match for `OptionalParametersCompilerCrash.AppDelegate.M(int, int, int)' does not contain a parameter named `whatever' (CS1739)

Along with the erroneous message:

> Error CS1744: Named argument `z' cannot be used for a parameter which has positional argument specified (CS1744) 

I'm using Monotouch, but presumably crash might happen in other environments.
Comment 1 Marek Safar 2013-09-25 04:54:44 UTC
Fixed in master