Compiler Happily Emits Task<void> #1830

Closed
SLaks opened this Issue Apr 7, 2015 · 7 comments

Comments

Projects
None yet
9 participants
@SLaks
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

This comment has been minimized.

Show comment
Hide comment
@AlgorithmsAreCool

AlgorithmsAreCool Apr 7, 2015

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

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

@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Apr 7, 2015

Contributor

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

Contributor

SLaks commented Apr 7, 2015

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

@RedwoodForest

This comment has been minimized.

Show comment
Hide comment

@SLaks @AlgorithmsAreCool This is suggested in #234.

@VSadov VSadov added this to the 1.0 (stable) milestone Apr 8, 2015

@gafter gafter added 2 - Ready 3 - Working and removed 2 - Ready labels Apr 8, 2015

@theoy

This comment has been minimized.

Show comment
Hide comment
@theoy

theoy Apr 9, 2015

Nice catch! :)

theoy commented Apr 9, 2015

Nice catch! :)

@AdamSpeight2008

This comment has been minimized.

Show comment
Hide comment
@AdamSpeight2008

AdamSpeight2008 Apr 12, 2015

Contributor

@SLaks

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

Contributor

AdamSpeight2008 commented Apr 12, 2015

@SLaks

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

@SLaks

This comment has been minimized.

Show comment
Hide comment
@SLaks

SLaks Apr 12, 2015

Contributor

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

Contributor

SLaks commented Apr 12, 2015

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

@gafter gafter closed this in #1910 Apr 14, 2015

@gafter

This comment has been minimized.

Show comment
Hide comment
@gafter

gafter Apr 14, 2015

Member

@AlekseyTs Can you "Verify" this please?

Member

gafter commented Apr 14, 2015

@AlekseyTs Can you "Verify" this please?

@gafter gafter assigned AlekseyTs and unassigned gafter Apr 14, 2015

@AlekseyTs AlekseyTs added the Verified label 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