fix(es/parser): Fix span for unterminated block comments (#9361)

**Related issue:**

 - https://github.com/wooorm/mdxjs-rs/pull/49
This commit is contained in:
Donny/강동윤 2024-08-01 14:16:17 +09:00 committed by GitHub
parent 9cd51cebdf
commit dc1b87e43e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
swc_common: patch
swc_ecma_parser: patch
---
fix(es/parser): Fix span for unterminated block comments

View File

@ -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

View File

@ -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)]