Closed
Description
In expression.rs
, we have some logic to avoid checking nested Union
operators, since our Union
checks operate recursively (and so re-checking nested Union
operators leads to duplicate diagnostics).
These checks don't quite work in .pyi
files due to the way we process deferred nodes. We don't store the current expression stack when snapshotting the SemanticModel
, because that would require us to store all expressions in an IndexVec
. This is a known source of bugs.
We can store the expressions in an IndexVec
, like we do for statements, but it will definitely hurt performance and increase memory usage.
As an example, if this is put in a .pyi
file:
from typing import Union
Union[int, Union[int, int]]
You'll hit duplicate violations:
foo.pyi:3:22: PYI016 Duplicate union member `int`
foo.pyi:3:27: PYI016 Duplicate union member `int`
foo.pyi:3:27: PYI016 Duplicate union member `int`