mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
feat(es/parser): Disallow tagged tpl in optional chaining (#7515)
This commit is contained in:
parent
b46bcf3f50
commit
6c00a2422a
@ -195,6 +195,7 @@ pub enum SyntaxError {
|
||||
TsBindingPatCannotBeOptional,
|
||||
SuperCallOptional,
|
||||
OptChainCannotFollowConstructorCall,
|
||||
TaggedTplInOptChain,
|
||||
|
||||
TrailingCommaInsideImport,
|
||||
|
||||
@ -470,6 +471,9 @@ impl SyntaxError {
|
||||
SyntaxError::OptChainCannotFollowConstructorCall => {
|
||||
"Constructor in/after an optional chaining is not allowed.".into()
|
||||
}
|
||||
SyntaxError::TaggedTplInOptChain => {
|
||||
"Tagged template literal is not allowed in optional chain.".into()
|
||||
}
|
||||
SyntaxError::TsInvalidParamPropPat => {
|
||||
"Typescript parameter property must be an identifier or assignment pattern".into()
|
||||
}
|
||||
|
@ -1060,6 +1060,11 @@ impl<I: Tokens> Parser<I> {
|
||||
let tpl = Box::new(self.parse_tpl(true)?);
|
||||
|
||||
let span = span!(self, tagged_tpl_start);
|
||||
|
||||
if tag.is_opt_chain() {
|
||||
self.emit_err(span, SyntaxError::TaggedTplInOptChain);
|
||||
}
|
||||
|
||||
Ok(TaggedTpl {
|
||||
span,
|
||||
tag,
|
||||
|
@ -0,0 +1 @@
|
||||
a?.b``
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Tagged template literal is not allowed in optional chain.
|
||||
,-[$DIR/tests/errors/optional-chaining/tagged-template.js:1:1]
|
||||
1 | a?.b``
|
||||
: ^^^^^^
|
||||
`----
|
Loading…
Reference in New Issue
Block a user