Skip to content

Commit

Permalink
Try to recover incomplete member declaration which looks like field. F…
Browse files Browse the repository at this point in the history
…ixes #7521
  • Loading branch information
marek-safar committed Mar 22, 2013
1 parent 12f8dd3 commit 8209756
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions mcs/errors/cs1519-5.cs
@@ -0,0 +1,7 @@
// CS1519: Unexpected symbol `}' in class, struct, or interface member declaration
// Line: 7

public class Foo
{
public f
}
20 changes: 19 additions & 1 deletion mcs/mcs/cs-parser.jay
Expand Up @@ -901,13 +901,14 @@ class_member_declaration
| destructor_declaration
| type_declaration
| attributes_without_members
| incomplete_member
| error
{
report.Error (1519, lexer.Location, "Unexpected symbol `{0}' in class, struct, or interface member declaration",
GetSymbolName (yyToken));
$$ = null;
lexer.parsing_generic_declaration = false;
}
}
;

struct_declaration
Expand Down Expand Up @@ -2526,6 +2527,23 @@ attributes_without_members
lexer.putback ('}');
}
;

// For full ast try to recover incomplete ambiguous member
// declaration in form on class X { public int }
incomplete_member
: opt_attributes opt_modifiers member_type CLOSE_BRACE
{
report.Error (1519, lexer.Location, "Unexpected symbol `}' in class, struct, or interface member declaration");

lexer.putback ('}');

lexer.parsing_generic_declaration = false;
FullNamedExpression type = (FullNamedExpression) $3;
current_field = new Field (current_type, type, (Modifiers) $2, MemberName.Null, (Attributes) $1);
current_type.AddField (current_field);
$$ = current_field;
}
;

enum_declaration
: opt_attributes
Expand Down

0 comments on commit 8209756

Please sign in to comment.