Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP 2
Browse files Browse the repository at this point in the history
overlookmotel committed Feb 28, 2024
1 parent 2696619 commit 0018477
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions crates/oxc_parser/src/lexer/source.rs
Original file line number Diff line number Diff line change
@@ -252,9 +252,14 @@ impl<'a> Source<'a> {
start: SourcePosition,
end: SourcePosition,
) -> &'a str {
// Check `start` and `end` are both within bounds of `Source`
debug_assert!(start.ptr <= end.ptr);
debug_assert!(start.ptr >= self.start);
debug_assert!(end.ptr <= self.end);
// Check `start` and `end` are both on UTF-8 character boundaries.
// SAFETY: `start` and `end` are valid to read from if they're not at EOF.
debug_assert!(start.ptr == self.end || !is_utf8_cont_byte(start.read()));
debug_assert!(end.ptr == self.end || !is_utf8_cont_byte(end.read()));

// SAFETY: Caller guarantees `start` is not after `end`.
// `SourcePosition`s can only be created from a `Source`.
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/lexer/template.rs
Original file line number Diff line number Diff line change
@@ -312,7 +312,7 @@ impl<'a> Lexer<'a> {
self.finish_next(kind)
}

/// Save template string
/// Save escaped template string
fn save_template_string(&mut self, is_valid_escape_sequence: bool, s: &'a str) {
self.escaped_templates.insert(self.token.start, is_valid_escape_sequence.then_some(s));
self.token.escaped = true;

0 comments on commit 0018477

Please sign in to comment.