Skip to content

Dynamic calls with universal-function-typed params fail with a confusing error #28105

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
vsmenon opened this issue Dec 14, 2016 · 3 comments
Closed
Assignees
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler

Comments

@vsmenon
Copy link
Member

vsmenon commented Dec 14, 2016

This:

T foo<T>(x) => x as T;

void main() {
  dynamic list = <Object>[1, 2, 3];
  var result = list.map(foo);
  print(list);
}

results in:

TypeError: obj[dartx.noSuchMethod] is not a function
    at dart.noSuchMethod (/Users/vsm/dart/sdk/pkg/dev_compiler/lib/js/common/dart_sdk.js:2023:37)
    at callNSM (/Users/vsm/dart/sdk/pkg/dev_compiler/lib/js/common/dart_sdk.js:1638:19)
    at dart._checkAndCall (/Users/vsm/dart/sdk/pkg/dev_compiler/lib/js/common/dart_sdk.js:1675:12)
    at dart._callMethod (/Users/vsm/dart/sdk/pkg/dev_compiler/lib/js/common/dart_sdk.js:1757:17)
    at dart.dsend (/Users/vsm/dart/sdk/pkg/dev_compiler/lib/js/common/dart_sdk.js:1760:17)
    at genlist.main (/Users/vsm/ddctest/genlist.js:20:23)
@vsmenon vsmenon added web-dev-compiler P2 A bug or feature request we're likely to work on labels Dec 14, 2016
@vsmenon
Copy link
Member Author

vsmenon commented Dec 14, 2016

@leafpetersen @jmesserly
Note, on the above, if I change dynamic to var, I get a static error:

[error] The argument type '<T>(dynamic) → T' can't be assigned to the parameter type '(Object) → dynamic'. (genlist.dart, line 5, col 25)

@davidmorgan hit this in json deserialization code, but we've worked around with more typing.

@vsmenon vsmenon added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Dec 14, 2016
@jmesserly
Copy link

jmesserly commented Dec 14, 2016

probably a similar issue as #28079 - RTTI is not working, so I can't imagine dcalls would work either.

@jmesserly jmesserly added this to the 1.50 milestone Dec 14, 2016
@jmesserly jmesserly self-assigned this Dec 15, 2016
@mit-mit mit-mit modified the milestones: 1.22, 1.50 Dec 28, 2016
@munificent munificent removed this from the 1.22 milestone Jan 12, 2017
@jmesserly jmesserly added this to the 1.23 milestone Mar 6, 2017
@vsmenon vsmenon removed this from the 1.23 milestone Mar 9, 2017
@jmesserly jmesserly self-assigned this Apr 4, 2017
@jmesserly
Copy link

It does show up correctly as a type error now.

The type doesn't display correctly, that's covered in #28079 so I'm going to close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler
Projects
None yet
Development

No branches or pull requests

4 participants