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

lack of return from static method doesn't cause error #4204

Closed
DartBot opened this issue Jul 25, 2012 · 4 comments
Closed

lack of return from static method doesn't cause error #4204

DartBot opened this issue Jul 25, 2012 · 4 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report

Comments

@DartBot
Copy link

DartBot commented Jul 25, 2012

This issue was originally filed by domi...@google.com


This code passed through analyzer, the dart vm, dart2js, and ran in dartium.

Vector {
  num x, y, z;
  Vector(this.x, this.y, this.z);
  static Vector normalize(Vector v) {
    if (v.length != 0.0)
      return Vector.multiply(v, 1.0 / length);
  }

It was only when I passed in Vector(0, 0, 0) that I tickled the bug and received back an undefined Vector from the JS version.

@lrhn
Copy link
Member

lrhn commented Jul 26, 2012

It should never be an error, since a function reaching the end of its body implicitly returns null.
Actually the spec says that is implicitly adds a "return null;" statement. That should probably be changed to an implicit "return;" statement, since the former will hide the problem here.

I think this should cause a static type warning, but as the spec is written, the "return null;" doesn't cause a warning. Had it been just "return;" it would be a static warning because the type "void" is not assignable to "Vector".

@lrhn
Copy link
Member

lrhn commented Jul 26, 2012

Added Area-Language label.

@dgrove
Copy link
Contributor

dgrove commented Jul 27, 2012

Set owner to @gbracha.
Added Triaged label.

@sethladd
Copy link
Contributor

Added Duplicate label.
Marked as being merged into #73.

@DartBot DartBot added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Jul 31, 2012
This issue was closed.
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). closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

5 participants