Skip to content

add hint about code that relies on fuzzy arrows #29299

Closed
@jmesserly

Description

@jmesserly

We'll have to check the places, but I think this is mainly:

  • subtype checks & assignability
  • type promotion (is checks)

The hint should instruct the user how to fix. For arity checks and types of variables, one can use Null as the parameter type instead of dynamic. To call a function like that one can cast to dynamic:

typedef TwoArgFunction(x, y);
test(g) {
  if (g is TwoArgFunction) print(g('hello ', 'world'));
}
main() {
  test((String x, String y) => x + y);
  test((int x, int y) => x + y);
}

new code:

typedef TwoArgFunction(Null x, Null y); // NOTE: Null
test(g) {
  if (g is TwoArgFunction) print((g as dynamic)('hello ', 'world')); // NOTE: cast
}
main() {
  test((String x, String y) => x + y);
  test((int x, int y) => x + y);
}

EDIT: marked this as a soundness issue because we don't really want to implement proper runtime checks for this. See blocked DDC bug #29295.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work ondevexp-warningIssues with the analyzer's Warning codeslegacy-area-analyzerUse area-devexp instead.soundnesstype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions