Describe the bug
Title says it all.
To Reproduce
See code below.
Expected behavior
At least the type inference should consistently Never _or_ Literal[2, 3] not both. Ideally, I would like it to be Literal[2, 3] without any error report (I used to see this behavior).
Screenshots or Code
class C:
member: Literal[1, 2, 3] = 1
c = C()
c.member
if c.member == 1:
...
elif c.member == 2: # pyright infers correctly the type of member `Literal[2, 3]`. However, it reports Cannot access member "member" for type "Never", too
...
d: Literal[1,2,3] = 1
if d == 1:
...
elif d == 2: # here, d is inferred as `Never`
...


VS Code extension or command-line
coc-pyright with pyright 1.1.65
Additional context
N/A
Issue number 1000. Yay!
Thanks for the bug report. This was caused by a bug in the logic I introduced for "discriminated union type narrowing" (#944). It will be fixed in the next release.
This is addressed in Pyright 1.1.67, which I just published. It will also be included in next week's release of Pylance.