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

crash on ClassifyUpdate for EventFields #35962

Merged
merged 1 commit into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6457,6 +6457,20 @@ public void FieldUpdate_FieldKind()
Diagnostic(RudeEditKind.FieldKindUpdate, "event Action a", CSharpFeaturesResources.event_field));
}

[Fact]
public void EventFieldUpdate_VariableDeclarator()
{
var src1 = "class C { event Action a; }";
var src2 = "class C { event Action a = () => { }; }";

var edits = GetTopEdits(src1, src2);

edits.VerifyEdits(
"Update [a]@23 -> [a = () => { }]@23");

edits.VerifyRudeDiagnostics();
}

[Fact]
public void FieldReorder()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ private void ClassifyUpdate(VariableDeclaratorSyntax oldNode, VariableDeclarator
}

// Check if a constant field is updated:
var fieldDeclaration = (FieldDeclarationSyntax)oldNode.Parent.Parent;
var fieldDeclaration = (BaseFieldDeclarationSyntax)oldNode.Parent.Parent;
if (fieldDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword))
{
ReportError(RudeEditKind.Update);
Expand Down