Skip to content

Change most specified warnings to errors #1012

@eernstg

Description

@eernstg

Cf. dart-lang/sdk#36127 and dart-lang/sdk#36126, the language specification specifies a few compile-time warnings:

  • It is a static warning if the return type of a user-declared operator []= is explicitly declared and not void. (E)
  • It is a static warning if a setter declares a return type other than void. (E)
  • It is a static warning if a class has a setter named v= with argument type T and a getter named v with return type S, and S may not be assigned to T. (E)
  • It is a static warning if an overriding method declaration declares a different default value for a parameter. (W)
  • A switch statement may yield static warnings for various non-exhaustive lists of cases. (W)
  • It is a static warning to import two different libraries with the same name unless their name is the empty string. (E)

However, the treatment of these warnings has been inconsistent for a long time.

The situations marked '(E)' are currently flagged as errors by the analyzer, and '(W)' is flagged as a warning. Given that the analyzer has flagged these situations as errors for a long time, we have the option to specify them as errors without breaking existing code.

This issue serves to discuss and clarify this situation.

Here is a concrete proposal: Change the specification to specify as errors those situations that are currently flagged as errors, as indicated above.

The treatment of the getter/setter type conflict is specified for null-safety, so it will be an error soon anyway, and similarly for the switch cases.

The examples in dart-lang/sdk#36127 would be adjusted and added as language tests.

@lrhn, @munificent, @leafpetersen, WDYT?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions