Skip to content

Commit

Permalink
Remove is_reserved_word
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 24, 2024
1 parent 7831ce0 commit d660b58
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 30 deletions.
9 changes: 0 additions & 9 deletions crates/swc_ecma_parser/src/parser/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@ impl<I: Tokens> ParseObject<Box<Expr>> for Parser<I> {
// `ident` from parse_prop_name is parsed as 'IdentifierName'
// It means we should check for invalid expressions like { for, }
if is_one_of!(self, '=', ',', '}') {
let is_reserved_word = { self.ctx().is_reserved_word(&ident.sym) };
if is_reserved_word {
self.emit_err(ident.span, SyntaxError::ReservedWordInObjShorthandOrPat);
}

if eat!(self, '=') {
let value = self.include_in_expr(true).parse_assignment_expr()?;
return Ok(PropOrSpread::Prop(Box::new(Prop::Assign(AssignProp {
Expand Down Expand Up @@ -494,10 +489,6 @@ impl<I: Tokens> ParseObject<Pat> for Parser<I> {
.parse_assignment_expr()
.map(Some)?
} else {
if self.ctx().is_reserved_word(&key.sym) {
self.emit_err(key.span, SyntaxError::ReservedWordInObjShorthandOrPat);
}

None
};

Expand Down
16 changes: 0 additions & 16 deletions crates/swc_ecma_parser/src/parser/stmt/module_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,6 @@ impl<I: Tokens> Parser<I> {
if possibly_orig_name.sym == "as" {
// `import { type as } from 'mod'`
if !is!(self, IdentName) {
if self.ctx().is_reserved_word(&possibly_orig_name.sym) {
syntax_error!(
self,
possibly_orig_name.span,
SyntaxError::ReservedWordInImport
)
}

if type_only {
self.emit_err(orig_name.span, SyntaxError::TS2206);
}
Expand Down Expand Up @@ -296,14 +288,6 @@ impl<I: Tokens> Parser<I> {
}));
}

// Handle difference between
//
// 'ImportedBinding'
// 'IdentifierName' as 'ImportedBinding'
if self.ctx().is_reserved_word(&orig_name.sym) {
syntax_error!(self, orig_name.span, SyntaxError::ReservedWordInImport)
}

let local = orig_name;
Ok(ImportSpecifier::Named(ImportNamedSpecifier {
span: span!(self, start),
Expand Down
5 changes: 0 additions & 5 deletions crates/swc_ecma_parser/src/parser/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ impl Context {
_ => false,
}
}

#[deprecated]
pub const fn is_reserved_word(self, _: &Atom) -> bool {
false
}
}

impl<I: Tokens> Parser<I> {
Expand Down

0 comments on commit d660b58

Please sign in to comment.