Skip to content

Spec grammar doesn't accept "covariant late final" instance field #1317

@munificent

Description

@munificent

The grammar rules for instance fields are:

declaration ::= // other rules...
  | 'covariant' 'late'? varOrType initializedIdentifierList
  | 'late'? 'final' type? initializedIdentifierList
  | 'late'? varOrType initializedIdentifierList

As far as I can tell, that prohibits:

class C {
  covariant late final int x;
}

The VM and analyzer accept this without error.

The corresponding rule for local variables and parameters is:

declaredIdentifier ::= 'covariant'? finalConstVarOrType identifier

finalConstVarOrType ::= 'late'? 'final' type?
  | 'const' type?
  | 'late'? varOrType

And that does let you get covariant late final, so it seems like this is likely a spec bug in declaration. (Though as far as I can tell it's never useful because you're either using declaredIdentifier for a local variable where covariant is prohibited or for a parameter where late is prohibited.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThere is a mistake in the language specification or in an active documentspecification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions