Summary
As the title says, invalid-syntax-in-forward-annotation does not preserve error spans. For example:
https://play.ty.dev/f034109f-c63d-4871-9976-dbea46491a62
The span of a's error is 1:8-1:9 (well actually it has two errors, but both are on the ]).
The span of b's error is the entire string literal. It would be nice if ty preserved the invalid-syntax error location and propagated it to invalid-syntax-in-forward-annotation
PS ~>Set-Content issue.py @'
a: type]
b: "type]"
'@
PS ~>uvx ty check issue.py
error[invalid-syntax]: Expected a statement
--> issue.py:1:8
|
1 | a: type]
| ^
2 | b: "type]"
|
error[invalid-syntax]: Expected a statement
--> issue.py:1:9
|
1 | a: type]
| ^
2 | b: "type]"
|
error[invalid-syntax-in-forward-annotation]: Syntax error in forward annotation: Unexpected token at the end of an expression
--> issue.py:2:4
|
1 | a: type]
2 | b: "type]"
| ^^^^^^^
|
info: rule `invalid-syntax-in-forward-annotation` is enabled by default
Found 3 diagnostics
The error message is also not always helpful, since the error may not occur at the end, ie type] | int
Version
ty 0.0.1-alpha.27 (26d7b68 2025-11-18)
Summary
As the title says,
invalid-syntax-in-forward-annotationdoes not preserve error spans. For example:https://play.ty.dev/f034109f-c63d-4871-9976-dbea46491a62
The span of
a's error is1:8-1:9(well actually it has two errors, but both are on the]).The span of
b's error is the entire string literal. It would be nice iftypreserved theinvalid-syntaxerror location and propagated it toinvalid-syntax-in-forward-annotationThe error message is also not always helpful, since the error may not occur at the end, ie
type] | intVersion
ty 0.0.1-alpha.27 (26d7b68 2025-11-18)