Bug 21808 - Internal compiler error when using "async delegate" syntax for a generic method argument.
Summary: Internal compiler error when using "async delegate" syntax for a generic meth...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 3.4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-08-05 00:47 UTC by bugzilla
Modified: 2014-08-06 01:56 UTC (History)
1 user (show)

Tags:
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:
Status:
RESOLVED FIXED

Description bugzilla 2014-08-05 00:47:42 UTC
The can be reproduced on both mono 3.4 and 3.6.  The following program causes the C# compiler to crash:

using System.Threading.Tasks;

class MainClass
{
	public static void Main(string [] args)
	{
		EnqueueTask(async delegate {
			await Task.Yield();
			return 0;
		});
	}
	
	static Task<T> EnqueueTask<T>(Func<Task<T>> func)
	{
		return null;
	}
}

The compiler error is "Error CS0584: Internal compiler error: Object reference not set to an instance of an object"

The same code works fine on Microsoft's compiler. The problem seems to be the usage of "async delegate" syntax.  No error is reported when the "delegate" keyword is changed to the lambda syntax "() =>".  It also seems to be related to the use of generics; no error is reported if type parameter "T" is removed from the EnqueueTask method.
Comment 1 Marek Safar 2014-08-06 01:52:37 UTC

*** This bug has been marked as a duplicate of bug 20849 ***
Comment 2 Marek Safar 2014-08-06 01:56:12 UTC
Already fixed in mono master