Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore debugger statement #3976

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading