-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Refine syntax error recovery for partial code to not interfere with non-error code. #17692
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3533,5 +3533,127 @@ void M() | |
EOF(); | ||
} | ||
|
||
[Fact, WorkItem(17683, "https://github.com/dotnet/roslyn/issues/17683")] | ||
public void Bug17683a() | ||
{ | ||
var source = | ||
@"from t in e | ||
where | ||
t == Int32. | ||
MinValue | ||
select t"; | ||
UsingExpression(source); | ||
N(SyntaxKind.QueryExpression); | ||
{ | ||
N(SyntaxKind.FromClause); | ||
{ | ||
N(SyntaxKind.FromKeyword); | ||
N(SyntaxKind.IdentifierToken, "t"); | ||
N(SyntaxKind.InKeyword); | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "e"); | ||
} | ||
} | ||
N(SyntaxKind.QueryBody); | ||
{ | ||
N(SyntaxKind.WhereClause); | ||
{ | ||
N(SyntaxKind.WhereKeyword); | ||
N(SyntaxKind.EqualsExpression); | ||
{ | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "t"); | ||
} | ||
N(SyntaxKind.EqualsEqualsToken); | ||
N(SyntaxKind.SimpleMemberAccessExpression); | ||
{ | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "Int32"); | ||
} | ||
N(SyntaxKind.DotToken); | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "MinValue"); | ||
} | ||
} | ||
} | ||
} | ||
N(SyntaxKind.SelectClause); | ||
{ | ||
N(SyntaxKind.SelectKeyword); | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "t"); | ||
} | ||
} | ||
} | ||
} | ||
EOF(); | ||
} | ||
|
||
[Fact] | ||
public void Bug17683b() | ||
{ | ||
var source = | ||
@"switch (e) | ||
{ | ||
case Int32. | ||
MaxValue when true: | ||
break; | ||
}"; | ||
UsingStatement(source); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is there a way to assert that there is no errors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the helper is taking expected diagnostics as an optional parameter. So the errors are checked. |
||
N(SyntaxKind.SwitchStatement); | ||
{ | ||
N(SyntaxKind.SwitchKeyword); | ||
N(SyntaxKind.OpenParenToken); | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "e"); | ||
} | ||
N(SyntaxKind.CloseParenToken); | ||
N(SyntaxKind.OpenBraceToken); | ||
N(SyntaxKind.SwitchSection); | ||
{ | ||
N(SyntaxKind.CasePatternSwitchLabel); | ||
{ | ||
N(SyntaxKind.CaseKeyword); | ||
N(SyntaxKind.ConstantPattern); | ||
{ | ||
N(SyntaxKind.SimpleMemberAccessExpression); | ||
{ | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "Int32"); | ||
} | ||
N(SyntaxKind.DotToken); | ||
N(SyntaxKind.IdentifierName); | ||
{ | ||
N(SyntaxKind.IdentifierToken, "MaxValue"); | ||
} | ||
} | ||
} | ||
N(SyntaxKind.WhenClause); | ||
{ | ||
N(SyntaxKind.WhenKeyword); | ||
N(SyntaxKind.TrueLiteralExpression); | ||
{ | ||
N(SyntaxKind.TrueKeyword); | ||
} | ||
} | ||
N(SyntaxKind.ColonToken); | ||
} | ||
N(SyntaxKind.BreakStatement); | ||
{ | ||
N(SyntaxKind.BreakKeyword); | ||
N(SyntaxKind.SemicolonToken); | ||
} | ||
} | ||
N(SyntaxKind.CloseBraceToken); | ||
} | ||
EOF(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to assert that there is no errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the helper is taking expected diagnostics as an optional parameter. So the errors are checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the helper doesn't really help the reader know that, though. I'll look at improving that in the future.