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

bug: incorrect assessment of unreachable code #1341

Open
flevi29 opened this issue Nov 8, 2024 · 0 comments
Open

bug: incorrect assessment of unreachable code #1341

flevi29 opened this issue Nov 8, 2024 · 0 comments

Comments

@flevi29
Copy link

flevi29 commented Nov 8, 2024

Related #318

sometest.ts

let one: number | undefined;
mainLoop: for (;;) {
  let two: number | undefined;
  for (;;) {
    if (one === 10) {
      break mainLoop;
    }

    if (two === 10) {
      break;
    }

    two = (two ?? 0) + 1;
  }

  one = (one ?? 0) + 1;
  console.log(one);
}

console.log("fnished!");

deno .\sometest.ts

1
2
3
4
5
6
7
8
9
10
fnished!

deno lint .\sometest.ts

error[no-unreachable]: This statement is unreachable
  --> C:\Users\anon\search_state\sometest.ts:16:3
   |
16 |   one = (one ?? 0) + 1;
   |   ^^^^^^^^^^^^^^^^^^^^^

  docs: https://lint.deno.land/rules/no-unreachable


error[no-unreachable]: This statement is unreachable
  --> C:\Users\anon\search_state\sometest.ts:17:3
   |
17 |   console.log(one);
   |   ^^^^^^^^^^^^^^^^^

  docs: https://lint.deno.land/rules/no-unreachable


Found 2 problems
Checked 1 file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant