Open
Description
Code like int foo,;
is currently parsed as having two variable declarations, which causes also FieldFragment
with null
name. But there is very little from the variable declaration, just a comma. And a better recovery would probably be just report that there is a not supported trailing comma, and don't create a new empty variable declaration.
test_XXX() {
var parseResult = parseStringWithErrors(r'''
class A {
int foo,;
}
''');
var node = parseResult.findNode.singleFieldDeclaration;
assertParsedNodeText(node, r'''
FieldDeclaration
fields: VariableDeclarationList
type: NamedType
name: int
variables
VariableDeclaration
name: foo
VariableDeclaration
name: <empty> <synthetic>
semicolon: ;
''');
}