Skip to content

Commit

Permalink
Prevent with statement in strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Lancaster committed Sep 26, 2020
1 parent 0108b80 commit 5fb2e64
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion boa/src/syntax/lexer/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{Cursor, Error, Tokenizer};
use crate::{
profiler::BoaProfiler,
syntax::{
ast::{Position, Span},
ast::{Keyword, Position, Span},
lexer::{Token, TokenKind},
},
};
Expand Down Expand Up @@ -68,6 +68,12 @@ impl<R> Tokenizer<R> for Identifier {
"null" => TokenKind::NullLiteral,
slice => {
if let Ok(keyword) = slice.parse() {
if strict_mode && keyword == Keyword::With {
return Err(Error::Syntax(
"using 'with' statement not allowed in strict mode".into(),
start_pos,
));
}
TokenKind::Keyword(keyword)
} else {
if strict_mode && STRICT_FORBIDDEN_IDENTIFIERS.contains(&slice) {
Expand Down

0 comments on commit 5fb2e64

Please sign in to comment.