Skip to content

Commit

Permalink
Disallow f-strings in match pattern literal
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Oct 9, 2023
1 parent 2d6557a commit 17dd524
Show file tree
Hide file tree
Showing 4 changed files with 6,247 additions and 6,174 deletions.
4 changes: 3 additions & 1 deletion crates/ruff_python_parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,9 @@ f'{f"{3.1415=:.1f}":*^20}'
{"foo " f"bar {x + y} " "baz": 10}
match foo:
case "foo " f"bar {x + y} " "baz":
case "one":
pass
case "implictly " "concatenated":
pass
f"\{foo}\{bar:\}"
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_python_parser/src/python.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ LiteralPattern: ast::Pattern = {
value: Box::new(value.into()),
range: (location..end_location).into()
}.into(),
<location:@L> <strings:StringLiteralOrFString+> <end_location:@R> =>? Ok(ast::PatternMatchValue {
<location:@L> <strings:StringLiteral+> <end_location:@R> =>? Ok(ast::PatternMatchValue {
value: Box::new(concatenate_strings(strings, (location..end_location).into())?),
range: (location..end_location).into()
}.into()),
Expand Down
Loading

0 comments on commit 17dd524

Please sign in to comment.