1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use rnode::VisitWith;
use stc_ts_ast_rnode::RCatchClause;

use crate::{
    analyzer::{pat::PatMode, scope::ScopeKind, Analyzer, Ctx},
    validator,
    validator::ValidateWith,
};

#[validator]
impl Analyzer<'_, '_> {
    fn validate(&mut self, s: &RCatchClause) {
        let ctx = Ctx {
            pat_mode: PatMode::Decl,
            ..self.ctx
        };
        self.with_ctx(ctx)
            .with_child(ScopeKind::Block, Default::default(), |child: &mut Analyzer| {
                match &s.param {
                    Some(pat) => {
                        pat.validate_with(child)?;
                    }
                    None => {}
                }

                s.body.visit_with(child);

                Ok(())
            })
    }
}