Skip to content

Commit 613756b

Browse files
authored
Add test case for fixed generic-dataclass crash (#12791)
Adds a test case for a crash that was fixed by #12762. Closes #12527.
1 parent 17aec67 commit 613756b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test-data/unit/check-dataclasses.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,3 +1712,15 @@ c: C[C]
17121712
d: C[str] # E: Type argument "str" of "C" must be a subtype of "C[Any]"
17131713
C(x=2)
17141714
[builtins fixtures/dataclasses.pyi]
1715+
1716+
[case testDataclassGenericBoundToInvalidTypeVarDoesNotCrash]
1717+
# flags: --python-version 3.7
1718+
import dataclasses
1719+
from typing import Generic, TypeVar
1720+
1721+
T = TypeVar("T", bound="NotDefined") # E: Name "NotDefined" is not defined
1722+
1723+
@dataclasses.dataclass
1724+
class C(Generic[T]):
1725+
x: float
1726+
[builtins fixtures/dataclasses.pyi]

0 commit comments

Comments
 (0)