Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Issue 1171283002: Updates for 1.10: warnings when for-in uses an expresison that has no iterator; assorted typos. (Closed)

Created:
5 years, 6 months ago by gbracha
Modified:
5 years, 6 months ago
Reviewers:
Paul Berry, rmacnak
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Updates for 1.10: warnings when for-in uses an expression that has no iterator; assorted typos. BUG= R=rmacnak@google.com Committed: https://github.com/dart-lang/sdk/commit/89607f06e9ccf9274f8ada2ecd4d004dbee9fb53

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -14 lines) Patch
M docs/language/dartLangSpec.tex View 15 chunks +42 lines, -14 lines 1 comment Download

Messages

Total messages: 6 (2 generated)
gbracha
5 years, 6 months ago (2015-06-09 21:55:30 UTC) #2
rmacnak
lgtm
5 years, 6 months ago (2015-06-09 22:37:30 UTC) #3
gbracha
Committed patchset #1 (id:1) manually as 89607f06e9ccf9274f8ada2ecd4d004dbee9fb53 (presubmit successful).
5 years, 6 months ago (2015-06-09 22:44:53 UTC) #4
Paul Berry
5 years, 6 months ago (2015-06-12 18:28:10 UTC) #6
Message was sent while issue was closed.
https://codereview.chromium.org/1171283002/diff/1/docs/language/dartLangSpec.tex
File docs/language/dartLangSpec.tex (right):

https://codereview.chromium.org/1171283002/diff/1/docs/language/dartLangSpec....
docs/language/dartLangSpec.tex:5644: It is a static warning if the static type
of $e$ does not have a member \cd{iterator}. It is a static warning if the
static type of \cd{$e$.iterator} does not have a method \cd{moveNext}. It is a
static warning if static return type of  \cd{$e$.iterator.moveNext()} is not
assignable to the static type of \cd{id}.
I don't think this is what we want:

1. It seems redundant to require that the static type of e has a member
"iterator", since the equivalent code above will have a static warning if it
doesn't.  However, if you are including this for completeness, then it is not
sufficient to require the static type of e to have a member "iterator".  We need
to require a *getter* called "iterator"; otherwise we won't catch the case where
the member "iterator" is an explicit setter that lacks a corresponding getter.

2. Requiring moveNext to be a method seems too broad.  The equivalent code above
allows moveNext to be a getter that returns a function, and the current vm and
dart2js implementations are consistent with this; so I think the static warnings
should permit moveNext to be a function-typed getter (or a getter whose type is
dynamic).

3. The static return type of moveNext needs to be be assignable to bool, since
in the equivalent code above, moveNext() is called in the condition of a while
loop.

4. There should be a static warning if moveNext has any required parameters.

5. There should be a static warning if the static type of e.iterator does not
have a getter called "current".

6. There should be a static warning if the static type of e.iterator.current is
not assignable to the static type of id.

As an alternative to spelling out all these cases, you might consider just
specifying that "for (finalConstVarOrType? id in e) s" has the same static
warnings as:

T n0 = e.iterator;
while (n0.moveNext()) {
  finalConstVarOrType? id = n0.current;
  s
}

where T is the static type of e.iterator.

Powered by Google App Engine
This is Rietveld 408576698