Skip to content

add hint about code that relies on fuzzy arrows #29299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jmesserly opened this issue Apr 6, 2017 · 1 comment
Closed

add hint about code that relies on fuzzy arrows #29299

jmesserly opened this issue Apr 6, 2017 · 1 comment
Labels
devexp-warning Issues with the analyzer's Warning codes legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on soundness type-enhancement A request for a change that isn't a bug

Comments

@jmesserly
Copy link

jmesserly commented Apr 6, 2017

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.

@bwilkerson bwilkerson added devexp-warning Issues with the analyzer's Warning codes P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Apr 10, 2017
@jmesserly
Copy link
Author

jmesserly commented May 30, 2017

I think we're going to eliminate fuzzy arrows directly rather than add a hint first, so closing this one out. EDIT: see #29630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-warning Issues with the analyzer's Warning codes legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on soundness type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants