question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong warning "Code is unreachable"

See original GitHub issue

https://github.com/microsoft/pyright/issues/1532

For some reason Pyright thinks this code is unreachable - this is clearly a mistake.

from contextlib import suppress

seconds = 0
with suppress(ValueError):
    seconds = int('a')

if not seconds:
    seconds = 42

Then it thinks all the other code, out of scope is broken too. Which is another (maybe consecutive) misconception.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
yaegassycommented, Mar 3, 2021

@kaldown Unfortunately, problems that cannot be reproduced cannot be solved. 😦

First, try updating to the latest version of coc-pyright. Currently, the latest version is v1.1.117.

I looked at your dotfile. https://github.com/kaldown/dotfiles/blob/master/.config/nvim/plug_config/base.vim#L64

Is your coc-pyright installed correctly? (Did you build the new version correctly?)

If you are installing with “vim-plug”, it is useful to set "Plug 'fannheyward/coc-pyright', {'do': 'yarn install --frozen-lockfile'}.

It is more useful if you use :CocInstall coc-pyright.

1reaction
yaegassycommented, Mar 3, 2021

I found a similar issue on pyright itself. https://github.com/microsoft/pyright/issues/1376

I forced the pyright version of coc-pyright to v1.1.101, and the “bug” was reproduced.

pyright-v1-1-101-bug
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unreachable code: error or warning? [closed]
A warning means that the compiler is capable of dealing with your code, but it believe that what you have written is wrong...
Read more >
Wrong warning "Code is unreachable" · Issue #1532
For some reason Pyright thinks this code is unreachable - this is clearly a mistake. from contextlib import suppress seconds = 0 with...
Read more >
Unreachable Code Error in Java
The Unreachable statements refers to statements that won't get executed during the execution of the program are called Unreachable ...
Read more >
Unreachable code warning not always showing up correctly
We ran into a weird thing today where a function suddenly started giving warnings about unreachable code, even though it hadn't been touched...
Read more >
Compiler Warning (level 4) C4702
When the compiler back end detects unreachable code, it generates C4702 as a level 4 warning. To address this warning, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found