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

Contextual return types for expression-bodied members #16044

Closed
SLaks opened this issue Dec 21, 2016 · 7 comments
Closed

Contextual return types for expression-bodied members #16044

SLaks opened this issue Dec 21, 2016 · 7 comments
Labels
Area-Compilers Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Pedantic ;) Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@SLaks
Copy link
Contributor

SLaks commented Dec 21, 2016

class C {
	partial A => new partial();
	async B => new async();
}

class partial {}
class async {}

The first line compiles; the second one does not.

Why not?
Why is async different from partial?

http://tryroslyn.azurewebsites.net/#b:master/f:>ilr/MYGwhgzhAEDC0G8BQBIADmATgFwJZhGgEFoBeAPmgDsBTAd2gx3xAAoBKAblUgE8rg0AEJlKtBnwEduAXyRJQkGEzwFEcxVGiTBCGUA=

@DavidArno
Copy link

DavidArno commented Dec 21, 2016

async is in scope as a keyword in this example as it could be the start of an async B F( ... method declaration.

@alrz
Copy link
Contributor

alrz commented Dec 21, 2016

@DavidArno So is partial in partial methods. Note that it will compile in other cases,

async M() => new async();
async M { get => new async(); }

@DavidArno
Copy link

Oh, I forgot about partial methods. In that case it does indeed appear to be a parser inconsistency issue.

@gafter gafter added this to the 2.1 milestone Dec 21, 2016
@gafter
Copy link
Member

gafter commented Dec 21, 2016

partial is a contextual keyword. The context is that the following token must be class, struct, or void.

async is a contextual keyword. It is treated as a keyword when it appears in a position that could be a member modifier.

They are different because they are specified to be different.

@gafter
Copy link
Member

gafter commented Dec 21, 2016

The spec does say, however

contextual keywords can conflict with declared names. In such cases, the declared name takes precedence over the use of the identifier as a contextual keyword.

@jaredpar jaredpar modified the milestones: Unknown, 15.1 Mar 9, 2017
@jaredpar jaredpar added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Mar 9, 2017
@jcouv jcouv added the 4 - In Review A fix for the issue is submitted for review. label Mar 26, 2018
@jcouv jcouv modified the milestones: Unknown, 15.7 Mar 26, 2018
@jaredpar jaredpar modified the milestones: 15.7, 15.8 Apr 2, 2018
@jcouv jcouv 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 5, 2018
@jcouv
Copy link
Member

jcouv commented Apr 5, 2018

Fix is in for 15.7 preview 4.

@jcouv jcouv closed this as completed Apr 5, 2018
@jcouv
Copy link
Member

jcouv commented Apr 5, 2018

Thanks @alrz for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Pedantic ;) Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

6 participants