[syntax-errors] Raise unsupported syntax error for template strings prior to Python 3.14 (#18664)

Closes #18662

One question is whether we would like the range to exclude the quotes?
This commit is contained in:
Dylan 2025-06-13 14:04:37 -05:00 committed by GitHub
parent 793ff9bdbc
commit 1889a5e6eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 459 additions and 2 deletions

View file

@ -1250,10 +1250,30 @@ impl<'src> Parser<'src> {
.into(),
));
} else if self.at(TokenKind::TStringStart) {
strings.push(StringType::TString(
// test_ok template_strings_py314
// # parse_options: {"target-version": "3.14"}
// t"{hey}"
// t'{there}'
// t"""what's
// happening?"""
// "implicitly"t"concatenated"
// test_err template_strings_py313
// # parse_options: {"target-version": "3.13"}
// t"{hey}"
// t'{there}'
// t"""what's
// happening?"""
// "implicitly"t"concatenated"
let string_type = StringType::TString(
self.parse_interpolated_string(InterpolatedStringKind::TString)
.into(),
));
);
self.add_unsupported_syntax_error(
UnsupportedSyntaxErrorKind::TemplateStrings,
string_type.range(),
);
strings.push(string_type);
}
}