Skip to content

Type-inference error not equating dynamic and Object #30829

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
floitschG opened this issue Sep 20, 2017 · 1 comment
Closed

Type-inference error not equating dynamic and Object #30829

floitschG opened this issue Sep 20, 2017 · 1 comment

Comments

@floitschG
Copy link
Contributor

/cc @leafpetersen

Take the following code:

void foo(void Function(Object) f) {  }

void main() {
  var f = (dynamic x) { };
  foo(f);
}

This should work: f has type dynamic -> void, or as the inference currently infers: dynamic -> Null.

However I get the following error message:

The argument type '(dynamic) → Null' can't be assigned to the parameter type '(Object) → void'.

I can remove this error message in two ways:

  1. change from dynamic to Object (which should be the same thing).
  2. change the return type from Null to void (by making it a nested function).

Neither should be necessary.

@leafpetersen
Copy link
Member

It will work as soon as I land the change to eliminate fuzzy arrows... :)

Changing the return type is a red herring - making a nested function changes it from a function typed variable (fuzzy arrow type) which can be re-assigned, to a concrete function which cannot be re-assigned (non-fuzzy arrow).

#29630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants