Skip to content

Commit

Permalink
fix: should panic if anonymous_expr is not called before class_reflec…
Browse files Browse the repository at this point in the history
…tion_decorator
  • Loading branch information
alekitto committed Oct 26, 2023
1 parent 539d4ef commit 60530d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl Program {

let mut transformers: Box<dyn Fold> = Box::new(chain!(
resolver(unresolved_mark, top_level_mark, self.is_typescript),
anonymous_expr(),
class_reflection_decorators(
self.filename.as_deref(),
opts.namespace.as_deref(),
Expand All @@ -66,7 +67,6 @@ impl Program {
strip(top_level_mark),
nullish_coalescing(Default::default()),
optional_chaining(Default::default(), unresolved_mark),
anonymous_expr(),
resolve_self_identifiers(unresolved_mark),
class_jobject(),
decorator_2022_03(),
Expand Down
3 changes: 2 additions & 1 deletion src/parser/transformers/class_reflection_decorators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ impl<C: Comments> VisitMut for ClassReflectionDecorators<'_, C> {
}

fn visit_mut_class_expr(&mut self, n: &mut ClassExpr) {
self.process_class(&mut n.class, n.ident.clone().unwrap());
let Some(ident) = n.ident.clone() else { panic!("anonymous_expr transformer must be called before class_reflection_decorator"); };
self.process_class(&mut n.class, ident);
n.visit_mut_children_with(self);
}
}

0 comments on commit 60530d9

Please sign in to comment.