Skip to content

Commit

Permalink
fix: ignore debugger statement (boa-dev#3976)
Browse files Browse the repository at this point in the history
Co-authored-by: shurizzle <me@shurizzle.dev>
  • Loading branch information
2 people authored and hansl committed Sep 12, 2024
1 parent f6fab08 commit 0cd01a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/ast/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ pub enum Expression {
/// It is not a valid expression node.
#[doc(hidden)]
FormalParameterList(FormalParameterList),

#[doc(hidden)]
Debugger,
}

impl Expression {
Expand Down Expand Up @@ -220,6 +223,7 @@ impl Expression {
Self::Parenthesized(expr) => expr.to_interned_string(interner),
Self::RegExpLiteral(regexp) => regexp.to_interned_string(interner),
Self::FormalParameterList(_) => unreachable!(),
Self::Debugger => "debugger".to_owned(),
}
}

Expand Down Expand Up @@ -326,7 +330,7 @@ impl VisitWith for Expression {
Self::Yield(y) => visitor.visit_yield(y),
Self::Parenthesized(e) => visitor.visit_parenthesized(e),
Self::FormalParameterList(fpl) => visitor.visit_formal_parameter_list(fpl),
Self::This | Self::NewTarget | Self::ImportMeta => {
Self::This | Self::NewTarget | Self::ImportMeta | Self::Debugger => {
// do nothing; can be handled as special case by visitor
ControlFlow::Continue(())
}
Expand Down Expand Up @@ -369,7 +373,7 @@ impl VisitWith for Expression {
Self::Yield(y) => visitor.visit_yield_mut(y),
Self::Parenthesized(e) => visitor.visit_parenthesized_mut(e),
Self::FormalParameterList(fpl) => visitor.visit_formal_parameter_list_mut(fpl),
Self::This | Self::NewTarget | Self::ImportMeta => {
Self::This | Self::NewTarget | Self::ImportMeta | Self::Debugger => {
// do nothing; can be handled as special case by visitor
ControlFlow::Continue(())
}
Expand Down
1 change: 1 addition & 0 deletions core/engine/src/bytecompiler/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ impl ByteCompiler<'_> {
}
// TODO: try to remove this variant somehow
Expression::FormalParameterList(_) => unreachable!(),
Expression::Debugger => (),
}
}
}
4 changes: 4 additions & 0 deletions core/parser/src/parser/expression/primary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ where
.parse(cursor, interner)
.map(Into::into)
}
TokenKind::Keyword((Keyword::Debugger, _)) => {
cursor.advance(interner);
Ok(ast::Expression::Debugger)
}
TokenKind::Keyword((Keyword::Async, contain_escaped_char)) => {
let contain_escaped_char = *contain_escaped_char;
let skip_n = if cursor.peek_is_line_terminator(0, interner).or_abrupt()? {
Expand Down

0 comments on commit 0cd01a2

Please sign in to comment.