[ty] Emit error for invalid binary operations in type expressions (#18991)

## Summary

This PR adds diagnostic for invalid binary operators in type
expressions. It should close https://github.com/astral-sh/ty/issues/706
if merged.

Please feel free to suggest better wordings for the diagnostic message.

## Test Plan

I modified `mdtest/annotations/invalid.md` and added a test for each
binary operator, and fixed tests that was broken by the new diagnostic.
This commit is contained in:
med1844
2025-06-30 01:06:01 -07:00
committed by GitHub
parent 9469a982cc
commit 0ec2ad2fa5
4 changed files with 46 additions and 2 deletions

View File

@@ -154,6 +154,7 @@ shouldn't panic.
```py
a: "1 or 2"
b: "(x := 1)"
# error: [invalid-type-form]
c: "1 + 2"
d: "lambda x: x"
e: "x if True else y"