Skip to content

Fix parsing an expression-bodied property with async as the type#25704

Merged
jcouv merged 3 commits intodotnet:dev15.7.xfrom
alrz:fix-async-prop
Apr 5, 2018
Merged

Fix parsing an expression-bodied property with async as the type#25704
jcouv merged 3 commits intodotnet:dev15.7.xfrom
alrz:fix-async-prop

Conversation

@alrz
Copy link
Copy Markdown
Member

@alrz alrz commented Mar 25, 2018

Fixes #16044

@alrz alrz requested a review from a team as a code owner March 25, 2018 11:55
@alrz
Copy link
Copy Markdown
Member Author

alrz commented Mar 25, 2018

PDBUsingTests failures don't seem to be related (passed locally).

@alrz
Copy link
Copy Markdown
Member Author

alrz commented Mar 25, 2018

@jaredpar I see these failures in my other PR as well. Is this a known issue on dev15.7.x?

@jaredpar
Copy link
Copy Markdown
Member

@alrz i haven't seen that. @333fred was tracking failures last week so he should know if they're a known issue. I don't thikn they are though but yeah it's strange that htey are on every PR

@jcouv jcouv added Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Mar 26, 2018
@jcouv jcouv added this to the 15.7 milestone Mar 26, 2018
}

[Fact]
[WorkItem(16044, "https://github.com/dotnet/roslyn/issues/16044")]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see TestPartiallyWrittenConstraintClauseInBaseList4 for a preferred style for writing such tests.

In order to author such a test, temporarily uncomment out the #define line at the top of ParsingTests.cs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferred style for writing such tests.

Didn't know that's preferable.
Done

Copy link
Copy Markdown
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@gafter
Copy link
Copy Markdown
Member

gafter commented Mar 26, 2018

@dotnet/roslyn-compiler Can we please have another review of this community-offered bug fix?

@jcouv
Copy link
Copy Markdown
Member

jcouv commented Mar 26, 2018

@dotnet/roslyn-infrastructure Is this issue with PDBUsingTests known?

Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks

@jasonmalinowski
Copy link
Copy Markdown
Member

I think it's "known" in the sense of "we just saw it fail in official builds an hour ago too, but don't have a better answer yet". @JieCarolHu can give a further update.

@gafter
Copy link
Copy Markdown
Member

gafter commented Mar 27, 2018

Please add a test for this case:

class Frog : I
{
    async I.T => null; // incorrect syntax error
}

interface I
{
    async T
    {
        get;
    }
}

class async
{
}

identifierOrThisOpt != null &&
(typeParameterListOpt != null && typeParameterListOpt.ContainsDiagnostics
|| this.CurrentToken.Kind != SyntaxKind.OpenParenToken && this.CurrentToken.Kind != SyntaxKind.OpenBraceToken) &&
|| this.CurrentToken.Kind != SyntaxKind.OpenParenToken && this.CurrentToken.Kind != SyntaxKind.OpenBraceToken && this.CurrentToken.Kind != SyntaxKind.EqualsGreaterThanToken) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is getting complex enough that i think extracting woudl be valuable. But up to you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One benefit of extraction is htat each case can be individually checked, with a nice comment explaining the real language construct this is looking for. I find that that is easier to read, review, and most importantly: maintain. Someone can see those checks and immediately start thinking to themselves "is there a another common case that is missing here?"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, what if i have "async this[...]". Do we have a problem here? you should have "identifierOrThisOpt"... but you'd have an OpenBracketToken not an openbrace.

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi Mar 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: if the indexer case works, it woudl still probably be helpful to add tests in this area for 'async' as the return type for all sorts of language constructs (i.e. operators, properties, indexers, etc.).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should read this piece to understand why we need to reconsider "async" to be a modifier in the first place. With partial there were no such ambiguities. @CyrusNajmabadi do you have any idea what we're trying to do here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope! hence why i wish this stuff was broken out into specific, documented, cases. Because trying to infer after the fact is super tough in these codeblocks that deal with very ambiguous code.

Copy link
Copy Markdown
Member Author

@alrz alrz Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, turns out it was doing somersault on ambiguities that we already dealt with for partial. Now it's hugely simplified and gives more accurate results: alrz@6a4d586

I figured the ScanPartial acts as a IsTrueModifier - just gives more details. that's why we can share many parts with ShouldAsyncTreatedAsModifier, however, the later has some specific preference that make these not so identical. I'll open a PR for further discussion when the other two are merged.

[WorkItem(16044, "https://github.com/dotnet/roslyn/issues/16044")]
public void AsyncAsType_ExpressionBodiedProperty()
{
UsingTree("class a { async b => null; }");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, that breaks my brain :)

@alrz
Copy link
Copy Markdown
Member Author

alrz commented Mar 27, 2018

I'm planning to do the same work for async that is being done for partial, to improve diagnostics. If there is no rush, I'll wait for that PR to merge first.

@jcouv
Copy link
Copy Markdown
Member

jcouv commented Mar 27, 2018

test this please

@alrz
Copy link
Copy Markdown
Member Author

alrz commented Mar 28, 2018

Consider:

class C
{
    async async

Which is preferable, FieldDeclaration or IncompleteMember?

@jcouv
Copy link
Copy Markdown
Member

jcouv commented Mar 28, 2018

@jaredpar Please approve for 15.7 ask-mode. Thanks

@alrz
Copy link
Copy Markdown
Member Author

alrz commented Mar 29, 2018

Not actionable failures.

@alrz
Copy link
Copy Markdown
Member Author

alrz commented Mar 31, 2018

(It's possible we skip this PR in favor of alrz@6a4d586 which is based on top of #23533)

@AlekseyTs
Copy link
Copy Markdown
Contributor

Test windows_debug_vs-integration_prtest please

@AlekseyTs
Copy link
Copy Markdown
Contributor

Test windows_release_vs-integration_prtest please

@AlekseyTs
Copy link
Copy Markdown
Contributor

@jcouv, @gafter Are you still good with the latest state of this PR? Please confirm.

@AlekseyTs
Copy link
Copy Markdown
Contributor

CC @jaredpar For approval

@jaredpar
Copy link
Copy Markdown
Member

jaredpar commented Apr 5, 2018

approved

Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM
Thanks

@jcouv jcouv merged commit 150784e into dotnet:dev15.7.x Apr 5, 2018
@alrz alrz deleted the fix-async-prop branch August 24, 2018 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved to merge Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants