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

Cascade specification doesn't allow static type checking. #19517

Closed
lrhn opened this issue Jun 18, 2014 · 3 comments
Closed

Cascade specification doesn't allow static type checking. #19517

lrhn opened this issue Jun 18, 2014 · 3 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lrhn
Copy link
Member

lrhn commented Jun 18, 2014

The specification of cascade invocation just says that e..suffix is equivalent to (t){t.suffix; return t;}(e) .
The "t" variable isn't typed, so there should be no warning for, e.g.,
  "abc"..noMethodNamedThis()
Also, the return type of the function literal is dynamic, so the type of e is lost there too:
  ("abc"..toString()).noMethodNamedThis()
should also not give a warning.

Could the spec of cascade be rewritten to not erase the type, e.g.,:
  ... equivalent to (((T t) { t.suffix; return t;})(e) as T) where T is the static type of e.

Or, alternatively, give static typing rules for cascades explicitly:
  e..suffix
has the static type T where T is the static type of e, and gives a warning if e.suffix would give a warning.

@gbracha
Copy link
Contributor

gbracha commented Aug 26, 2014

Set owner to @gbracha.
Added Accepted label.

@gbracha
Copy link
Contributor

gbracha commented Aug 26, 2014

Usually, enhancement requests masquerade as defects. This is the first time I've seen it go the other way.


Removed Type-Enhancement label.
Added Type-Defect label.

@lrhn lrhn added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 26, 2014
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed accepted labels Feb 29, 2016
@lrhn
Copy link
Member Author

lrhn commented Jun 22, 2018

The cascade specification has been rewritten. It is no longer rewritten as a function invocation.
It still doesn't say what the static type is. I'll fix that.

@lrhn lrhn closed this as completed Jun 22, 2018
dart-bot pushed a commit that referenced this issue Jun 22, 2018
Don't use $e$ for two different things, and specify static type.

Fixes #19517.

Bug: http://dartbug.com/19517
Change-Id: Ieb30fc05dc305f25526b05b2005a1a81a88e2009
Reviewed-on: https://dart-review.googlesource.com/61881
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants