Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Happily Emits Task<void> #1830

Closed
SLaks opened this issue Apr 7, 2015 · 7 comments · Fixed by #1910
Closed

Compiler Happily Emits Task<void> #1830

SLaks opened this issue Apr 7, 2015 · 7 comments · Fixed by #1910
Labels
Area-Compilers Bug Language-C# Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Verified
Milestone

Comments

@SLaks
Copy link
Contributor

SLaks commented Apr 7, 2015

Source:

var t = Task.Run(() => {
    return Console.Beep();
});

This should not compile!

The IDE also happily reports that t is a Task<void>.
Running it throws a TypeLoadException: The generic type 'System.Func1' was used with an invalid instantiation in assembly mscorlib`

@AlgorithmsAreCool
Copy link

Despite this being an obvious bug, i wish it was legal to use void as a generic parameter.

@SLaks
Copy link
Contributor Author

SLaks commented Apr 7, 2015

@AlgorithmsAreCool Feel free to file a feature request in dotnet/coreclr.

@RedwoodForest
Copy link

@SLaks @AlgorithmsAreCool This is suggested in #234.

@theoy
Copy link
Contributor

theoy commented Apr 9, 2015

Nice catch! :)

gafter added a commit to gafter/roslyn that referenced this issue Apr 10, 2015
@gafter gafter added 4 - In Review A fix for the issue is submitted for review. and removed 3 - Working labels Apr 10, 2015
@AdamSpeight2008
Copy link
Contributor

@SLaks

Let's say the CLR allowed Func<Void> how would it work with Action<>, especially overload resolution?

@SLaks
Copy link
Contributor Author

SLaks commented Apr 12, 2015

@AdamSpeight2008 Action would take precendence, just like Func<int> vs delegate int MyDelegate();.

@gafter gafter added Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented and removed 4 - In Review A fix for the issue is submitted for review. labels Apr 14, 2015
@gafter
Copy link
Member

gafter commented Apr 14, 2015

@AlekseyTs Can you "Verify" this please?

@gafter gafter assigned AlekseyTs and unassigned gafter Apr 14, 2015
@AlekseyTs AlekseyTs removed their assignment Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Language-C# Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented Verified
Projects
None yet
9 participants