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

Making dart2js warnings consistent #11266

Closed
sigmundch opened this issue Jun 13, 2013 · 8 comments
Closed

Making dart2js warnings consistent #11266

sigmundch opened this issue Jun 13, 2013 · 8 comments
Assignees
Labels
closed-obsolete Closed as the reported issue is no longer relevant P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@sigmundch
Copy link
Member

I found this strange bug in dart2js warnings. Consider the following code:
 
main() {
  int x = compute(3);
  m1(x);
  m2(x);
  m3(x);
  m4(x);
}

void m4(int d) {
  switch(d) {
    default:
      if (d > 10) {
        throw "foo";
      } else {
        return;
      }
      d++;
  }
}

void m3(int c) {
  if (c > 10) {
    throw "foo";
  } else {
    return;
  }
  c++;
}

void m2(int b) {
  switch(b) {
    default:
      throw "a";
      b++;
  }
}

void m1(int a) {
  throw "foo";
  a++;
}

int compute(y) => y == 0 ? y : y * compute(y - 1);


  1. Calling dart2js on this program produces:
    program:warning.dart:17:7: Warning: unreachable code
          d++;
          ^^^^
    warning.dart:27:3: Warning: unreachable code
      c++;
      ^^^^
    warning.dart:34:7: Warning: unreachable code
          b++;
          ^^^^
    warning.dart:40:3: Warning: unreachable code
      a++;
      ^^^^
    Dart file warning.dart compiled to JavaScript: out.js

This looks great!

  1. Comment out the calls to m1, m2 and m3, then the output becomes:
    warning.dart:17:7: Warning: unreachable code
          d++;
          ^^^^
    warning.dart:17:7: Warning: dead code
          d++;
          ^^^^
    Dart file warning.dart compiled to JavaScript: out.js

Strangely: the error on d++ is reported twice, and the second time uses a different error message.

@sigmundch
Copy link
Member Author

I forgot to mention that you can isolate the duplicate message as shown below, but I was showing the bigger example to highlight that this is hidden when there are other warnings around, and that it seems to happen on more complex code (any of the cases m1, m2, or m3 does't report "dead code"):

main() {
  int x = compute(3);
  switch(x) {
    default:
      if (x > 10) {
        throw "foo";
      } else {
        return;
      }
      x++;
  }
}

int compute(y) => y == 0 ? y : y * compute(y - 1);

@kasperl
Copy link

kasperl commented Jun 13, 2013

Added this to the M6 milestone.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@larsbak
Copy link

larsbak commented Aug 28, 2013

Removed this from the M6 milestone.
Added this to the M7 milestone.

@karlklose
Copy link
Contributor

Set owner to @karlklose.
Added Accepted label.

@kasperl
Copy link

kasperl commented Oct 2, 2013

Removed this from the M7 milestone.
Added this to the M8 milestone.

@kasperl
Copy link

kasperl commented Jun 4, 2014

Removed this from the M8 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-1.6 label.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed accepted labels Feb 29, 2016
@sigmundch sigmundch added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants