-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
Example:
class C {
int x;
C.n1(this.x) : x = x; // INVALID
C.n2(int x) : x = x, x = x; // INVALID
}
void main() {}The specification states:
It is a compile-time error if more than one initializer corresponding
to a given instance variable appears in $k$'s initializer list.
It is a compile-time error if $k$'s initializer list contains
an initializer for a variable that is initialized by means of
an initializing formal of $k$.so both C.n1 and C.n2 should be errors.
The analyzer fails to report C.n1 and C.n2 as errors, the CFE reports:
invalidreinit.dart:3:20: Error: 'x' was already initialized by this constructor.
C.n1(this.x) : x = x; // INVALID
^
invalidreinit.dart:4:26: Error: 'x' was already initialized by this constructor.
C.n2(int x) : x = x, x = x; // INVALID
^srawlins
Metadata
Metadata
Assignees
Labels
area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)