Skip to content

Include import prefixes on type error messages - dart2js #33696

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

Open
srawlins opened this issue Jun 28, 2018 · 0 comments
Open

Include import prefixes on type error messages - dart2js #33696

srawlins opened this issue Jun 28, 2018 · 0 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js

Comments

@srawlins
Copy link
Member

Similar to #33667 (CFE), #33693 (VM), and #33695 (DDC).

Here's a dartpad. Code:

import 'dart:math' as math;

// Poorly named wrapper for math.Random
class Random {
  math.Random inner;

  Random(this.inner);
}

void main() {
  List<Random> list = new List<Random>()..add(new Random(new math.Random(7)));
  addRandom(list.map((e) => e.inner));
}

addRandom(List<math.Random> list) => list..add(new math.Random());

Here's the runtime error:

Uncaught exception:
TypeError: Instance of 'MappedListIterable<Random, Random0>': type 'MappedListIterable<Random, Random0>' is not a subtype of type 'List<Random0>'

Instead of Random0 (or in addition, whatever). It'd be nice if the error respected the prefixes that the user uses in their code, a step they've already taken to de-conflate the two classes, to read:

Uncaught exception:
TypeError: Instance of 'MappedListIterable<Random, math.Random>': type 'MappedListIterable<Random, math.Random>' is not a subtype of type 'List<math.Random>'

Or if its easier to not include a ., this would be fine:

Uncaught exception:
TypeError: Instance of 'MappedListIterable<Random, math_Random>': type 'MappedListIterable<Random, math_Random>' is not a subtype of type 'List<math_Random>'

@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-dart2js
Projects
None yet
Development

No branches or pull requests

3 participants