Separate terminator token for f-string elements kind (#11842)

## Summary

This PR separates the terminator token for f-string elements depending
on the context. A list of f-string element can occur either in a regular
f-string or a format spec of an f-string. The terminator token is
different depending on that context.

## Test Plan

`cargo insta test` and verify the updated snapshots.
This commit is contained in:
Dhruv Manilawala 2024-06-12 13:57:35 +05:30 committed by GitHub
parent 93973b96cb
commit a525b4be3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 73 additions and 44 deletions

View file

@ -11,15 +11,15 @@ Module(
body: [
Expr(
StmtExpr {
range: 0..14,
range: 0..16,
value: FString(
ExprFString {
range: 0..14,
range: 0..16,
value: FStringValue {
inner: Single(
FString(
FString {
range: 0..14,
range: 0..16,
elements: [
Expression(
FStringExpressionElement {
@ -110,17 +110,5 @@ Module(
|
1 | f"{lambda x: x}"
| ^ Syntax Error: Expected FStringEnd, found '}'
|
|
1 | f"{lambda x: x}"
| ^ Syntax Error: Expected a statement
|
|
1 | f"{lambda x: x}"
| ^ Syntax Error: Expected a statement
| ^ Syntax Error: Expected an f-string element or the end of the f-string
|

View file

@ -116,7 +116,7 @@ Module(
|
1 | f"hello {x:"
| ^ Syntax Error: f-string: expecting '}'
| ^ Syntax Error: Expected an f-string element or a '}'
2 | f"hello {x:.3f"
|
@ -124,7 +124,7 @@ Module(
|
1 | f"hello {x:"
2 | f"hello {x:.3f"
| ^ Syntax Error: f-string: expecting '}'
| ^ Syntax Error: Expected an f-string element or a '}'
|

View file

@ -335,7 +335,7 @@ Module(
4 | 2 + 2
5 | f"hello {x:
6 | 3 + 3
| ^ Syntax Error: Expected an f-string element or the end of the f-string
| ^ Syntax Error: Expected an f-string element or a '}'
7 | f"hello {x}
8 | 4 + 4
|