Skip to content
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

Imprecise type analysis for document.body.nodes. #1398

Closed
stevemessick opened this issue Jan 31, 2012 · 3 comments
Closed

Imprecise type analysis for document.body.nodes. #1398

stevemessick opened this issue Jan 31, 2012 · 3 comments
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@stevemessick
Copy link
Contributor

import("dart:html");

void main() {
  document.body.nodes. ;
}

Type analysis works for document and body; code completion works for both. nodes is getting typed as <dynamic> when it should be NodeList.

Priority is bumped since people are complaining about the lack of code completion.

@stevemessick
Copy link
Contributor Author

Marked this as blocking #1157.

@stevemessick
Copy link
Contributor Author

Matt and I looked into this and have a very simple repro case that illustrates the problem. First, the problem is that untyped setters are overwriting type analyses performed for typed getters. In the dart:html code the getters usually appear first lexically and some of the setters have complex types that (historically and perhaps currently) didn't work too well, so they were omitted. The TypeAnalyzer does allows the last writer to win, so the type of a field that was determined by a getter is irrelevant if the class defines a setter after the getter.

Here's Matt's example that uses only core classes:

void main() {
  print("hello");
  Zebra z = new Zebra();
  z.today. /completion/ day. /completion/ toString();
  print("done");
}

class Zebra {
  void set today(value) {
  }
  Date get today() {
    return new Date.now();
  }
}

In this form completion works at the indicated locations, just as expected.

Reversing the order of the getter and setter causes completion to fail because the setter has no type information for its parameter.

Since completion is only interested in the type of the getter, which is the case for most operations other than assignment, it isn't clear why the parameter type of the setter is even being used by type analysis. The spec says a warning should be issued for mis-matched types of getter and setter value but type analysis isn't even generating a warning (and that should probably be done elsewhere, anyway).

@DartBot
Copy link

DartBot commented Mar 8, 2012

This comment was originally written by [email protected]


Issue #380 has been fixed. I verfied this problem is fixed in the editor too as of build 5182.


Added Fixed label.

@stevemessick stevemessick added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures labels Mar 8, 2012
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

2 participants