You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When compiling tests/co19/src/LanguageFeatures/Enhanced-Enum/enum_name_A01_t01.dart with sound null safety the following compile-time errors are issued:
tests/co19/src/LanguageFeatures/Enhanced-Enum/enum_name_A01_t01.dart:30:6: Error: Constant evaluation error:
enum E<T extends num> {
^
tests/co19/src/LanguageFeatures/Enhanced-Enum/enum_name_A01_t01.dart:30:6: Context: Expected constant 'null' to be of type 'E<dynamic>', but was of type 'Null'.
- 'E' is from 'tests/co19/src/LanguageFeatures/Enhanced-Enum/enum_name_A01_t01.dart'.
enum E<T extends num> {
^
tests/co19/src/LanguageFeatures/Enhanced-Enum/enum_name_A01_t01.dart:30:6: Context: While analyzing:
enum E<T extends num> {
^
However, when compiling and running with --no-sound-null-safety, this test compiles without errors and fails at run time.
Kernel generated by the front-end doesn't look right:
Both e1 and e2 enum elements are declared as null constants (#C1). This causes the test to fail with RuntimeError in dartk-weak-asserts-* configurations.
I think it's a case of a test that needs correction and the lack of a compile-time error message from the CFE. If I'm reading the spec correctly, the default constructor for the enum is not generated if it has a generative constructor or an unnamed factory:
Default constructor: If no generative constructors were declared, and no unnamed factory constructor was added, a default generative constructor is added:
const Name();
(This differs from the default constructor of a normal class declaration by being constant.)
So what I think happens is that the declaration of E.name prevents the CFE from generating the default constructor, making the declarations of the elements e1 and e2 erroneous. The CFE doesn't report in that case yet and silently uses null as the value for both of the elements.
This is a part of #47453.
When compiling
tests/co19/src/LanguageFeatures/Enhanced-Enum/enum_name_A01_t01.dart
with sound null safety the following compile-time errors are issued:However, when compiling and running with
--no-sound-null-safety
, this test compiles without errors and fails at run time.Kernel generated by the front-end doesn't look right:
Both
e1
ande2
enum elements are declared asnull
constants (#C1
). This causes the test to fail withRuntimeError
in dartk-weak-asserts-* configurations./cc @chloestefantsova @johnniwinther
The text was updated successfully, but these errors were encountered: