Skip to content

Commit e0fe608

Browse files
committed
Use KNOWN_RANGE for string/t-string mix error messages
1 parent 860f81d commit e0fe608

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

Grammar/python.gram

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,8 +1557,10 @@ invalid_tstring_conversion_character:
15571557
| '!' !NAME { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("t-string: invalid conversion character") }
15581558

15591559
invalid_string_tstring_concat:
1560-
| (fstring|string)+ a[expr_ty]=tstring { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot mix t-strings with strings or f-strings") }
1561-
| tstring+ a[expr_ty]=(fstring|string) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot mix t-strings with strings or f-strings") }
1560+
| a=(fstring|string)+ b[expr_ty]=tstring {
1561+
RAISE_SYNTAX_ERROR_KNOWN_RANGE(PyPegen_last_item(a, expr_ty), b, "cannot mix t-strings with strings or f-strings") }
1562+
| a=tstring+ b[expr_ty]=(fstring|string) {
1563+
RAISE_SYNTAX_ERROR_KNOWN_RANGE(PyPegen_last_item(a, expr_ty), b, "cannot mix t-strings with strings or f-strings") }
15621564

15631565
invalid_arithmetic:
15641566
| sum ('+'|'-'|'*'|'/'|'%'|'//'|'@') a='not' b=inversion { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "'not' after an operator must be parenthesized") }

Parser/parser.c

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)