Skip to content

Evaluate Xyz.fromEnvironment() as unknown value. #50045

@scheglov

Description

@scheglov

We don't know which value we will get, so it is fair to say that the value is unknown.

The implementation is relatively straightforward.

But it breaks a couple of language/ tests, e.g. language/type/constants_test/07, which can be reduced to:

const bool fromEnvironment =
    const bool.fromEnvironment("foo", defaultValue: true);

void testSwitch(args) {
  switch (args) {
    case fromEnvironment ? const MyType() : Type: //# 07: compile-time error
  }
}

class MyType implements Type {
  const MyType();
  bool operator ==(Object other) => identical(this, other);
}

We stopped reporting the compile-time error, because the result of evaluating fromEnvironment ? const MyType() : Type is unknown, which does not implement operator ==.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestanalyzer-constantsarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.model-const-evalImplementation of constant evaluation in analyzer/cfetype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions