diff --git a/crates/oxc_parser/src/jsx/mod.rs b/crates/oxc_parser/src/jsx/mod.rs index 748480f5bf6a0..c666686a0511d 100644 --- a/crates/oxc_parser/src/jsx/mod.rs +++ b/crates/oxc_parser/src/jsx/mod.rs @@ -198,7 +198,12 @@ impl<'a> ParserImpl<'a> { } // - property = Some(self.parse_jsx_identifier()?); + let ident = self.parse_jsx_identifier()?; + // `` is a syntax error. + if ident.name.contains('-') { + return Err(diagnostics::unexpected_token(ident.span)); + } + property = Some(ident); span = self.end_span(span); } diff --git a/tasks/coverage/misc/fail/oxc-5355.jsx b/tasks/coverage/misc/fail/oxc-5355.jsx new file mode 100644 index 0000000000000..bbf550bea8e8b --- /dev/null +++ b/tasks/coverage/misc/fail/oxc-5355.jsx @@ -0,0 +1 @@ + diff --git a/tasks/coverage/parser_misc.snap b/tasks/coverage/parser_misc.snap index 6ee26030e24f6..5365b6458234c 100644 --- a/tasks/coverage/parser_misc.snap +++ b/tasks/coverage/parser_misc.snap @@ -1,7 +1,7 @@ parser_misc Summary: AST Parsed : 27/27 (100.00%) Positive Passed: 27/27 (100.00%) -Negative Passed: 16/16 (100.00%) +Negative Passed: 17/17 (100.00%) × Unexpected token ╭─[misc/fail/oxc-169.js:2:1] @@ -238,6 +238,12 @@ Negative Passed: 16/16 (100.00%) 5 │ } ╰──── + × Unexpected token + ╭─[misc/fail/oxc-5355.jsx:1:6] + 1 │ + · ─────── + ╰──── + × The keyword 'let' is reserved ╭─[misc/fail/oxc.js:1:1] 1 │ let.a = 1;