F-string error recovery within list parsing is good but it breaks when it's within a parenthesized context.
For example,
bad_function_call(
param1=f'test
param2='test'
)
The re-lexing will reduce the nesting level when recovering from an unclosed f-string but the lexer isn't in an expression element so the nesting level it reduced is the one from the outer context. This means that it'll emit an Indent token before param2 which is incorrect.
Another example is when the parser is recovering from within a format spec,
bad_function_call(
param1=f'test{x:.3f,
param2='test'
)
Here, the parser uses the same list parsing logic for parsing both the outer f-string elements and the ones in the format specifier. This means that when it tries to recover from an unclosed f-string, it reduces the nesting level twice (1) when re-lexing from the format spec and (2) when re-lexing from the outer f-string.
Todo
F-string error recovery within list parsing is good but it breaks when it's within a parenthesized context.
For example,
The re-lexing will reduce the nesting level when recovering from an unclosed f-string but the lexer isn't in an expression element so the nesting level it reduced is the one from the outer context. This means that it'll emit an
Indenttoken beforeparam2which is incorrect.Another example is when the parser is recovering from within a format spec,
Here, the parser uses the same list parsing logic for parsing both the outer f-string elements and the ones in the format specifier. This means that when it tries to recover from an unclosed f-string, it reduces the nesting level twice (1) when re-lexing from the format spec and (2) when re-lexing from the outer f-string.
Todo
fstring.is_in_expression)