Wrong warning "Code is unreachable"
See original GitHub issuehttps://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:
- Created 3 years ago
- Comments:17 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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
.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.