Skip to content

Missing type information in expression compilation can cause valid expression to be compiled incorrectly #32127

Open
@sjindel-google

Description

@sjindel-google

Currently the API for expression compilation in the front end is provided a set of Strings representing
the variables in scope. CFE gives all these variables the type dynamic. This can lead to some types being incorrectly inferred:

Source code:

class D<T> {
  Y id<Y>(Y x) => x;
  m(List<T> l);
  foo() {
    List<T> s;
    // breakpoint here
  }
}

Expression:

m(id(s = []))

Since the type of s is seen as dynamic, CFE will output:

method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic s) → dynamic
  return this.{main::D::m}(this.{main::D::id}(let dynamic _ = null in s = <dynamic>[]));

This will raise a runtime type error when entering m, whereas if the user had actually written this expression at the breakpoint, it would run ok.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions