Skip to content

Commit

Permalink
UPdate how we parse MemberAccess expressions as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Dec 14, 2016
1 parent 426677b commit 0851ac8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9678,6 +9678,26 @@ private ExpressionSyntax ParsePostFixExpression(ExpressionSyntax expr)
expr = _syntaxFactory.MemberAccessExpression(SyntaxKind.PointerMemberAccessExpression, expr, this.EatToken(), this.ParseSimpleName(NameOptions.InExpression));
break;
case SyntaxKind.DotToken:
// if we have the error situation:
//
// expr.
// X Y
//
// Then we don't want to parse this out as "Expr.X"
//
// It's far more likely the member access expression is simply incomplete and
// there is a new declaration on the next line.
if (this.CurrentToken.TrailingTrivia.Any((int)SyntaxKind.EndOfLineTrivia) &&
this.PeekToken(1).Kind == SyntaxKind.IdentifierToken &&
this.PeekToken(2).Kind == SyntaxKind.IdentifierToken)
{
expr = _syntaxFactory.MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression, expr, this.EatToken(),
this.AddError(this.CreateMissingIdentifierName(), ErrorCode.ERR_IdentifierExpected));

return expr;
}

expr = _syntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, expr, this.EatToken(), this.ParseSimpleName(NameOptions.InExpression));
break;

Expand Down

0 comments on commit 0851ac8

Please sign in to comment.