From bf1cdfaf7717d93b04d6d13cbe66ee7982265736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4=20=28Donny=29?= Date: Thu, 1 Aug 2024 13:43:24 +0900 Subject: [PATCH 1/2] fix --- crates/swc_common/src/input.rs | 8 ++++++++ crates/swc_ecma_parser/src/lexer/util.rs | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/swc_common/src/input.rs b/crates/swc_common/src/input.rs index bc6fb1644935..d42cccbd3e97 100644 --- a/crates/swc_common/src/input.rs +++ b/crates/swc_common/src/input.rs @@ -49,6 +49,14 @@ impl<'a> StringInput<'a> { self.reset_to(self.last_pos + BytePos(n as u32)); } } + + pub fn start_pos(&self) -> BytePos { + self.orig_start + } + + pub fn end_pos(&self) -> BytePos { + self.last_pos + } } /// Creates an [Input] from [SourceFile]. This is an alias for diff --git a/crates/swc_ecma_parser/src/lexer/util.rs b/crates/swc_ecma_parser/src/lexer/util.rs index 578944aa11df..f67c4911ea1b 100644 --- a/crates/swc_ecma_parser/src/lexer/util.rs +++ b/crates/swc_ecma_parser/src/lexer/util.rs @@ -290,7 +290,8 @@ impl<'a> Lexer<'a> { self.bump(); } - self.emit_error(start, SyntaxError::UnterminatedBlockComment) + let span = Span::new(start, self.input.end_pos()); + self.emit_error_span(span, SyntaxError::UnterminatedBlockComment) } #[inline(never)] From fb7fcc1d2a9532b5e2b5bd811cc36a8252889b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 1 Aug 2024 13:45:50 +0900 Subject: [PATCH 2/2] Create large-glasses-move.md --- .changeset/large-glasses-move.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/large-glasses-move.md diff --git a/.changeset/large-glasses-move.md b/.changeset/large-glasses-move.md new file mode 100644 index 000000000000..3ddeff66336d --- /dev/null +++ b/.changeset/large-glasses-move.md @@ -0,0 +1,6 @@ +--- +swc_common: patch +swc_ecma_parser: patch +--- + +fix(es/parser): Fix span for unterminated block comments