2021-12-07 08:34:16 +03:00
|
|
|
use swc_common::{input::StringInput, FileName};
|
2021-08-14 21:34:14 +03:00
|
|
|
use swc_ecma_ast::*;
|
|
|
|
use swc_ecma_parser::{lexer::Lexer, Parser};
|
2021-12-07 08:34:16 +03:00
|
|
|
use swc_ecma_visit::{All, VisitAll, VisitWith};
|
2021-08-14 21:34:14 +03:00
|
|
|
|
|
|
|
struct Issue1967;
|
|
|
|
|
|
|
|
impl VisitAll for Issue1967 {
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_expr(&mut self, _: &Expr) {
|
2021-08-14 21:34:14 +03:00
|
|
|
panic!("intended")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic = "intended"]
|
|
|
|
fn issue_1967() {
|
|
|
|
testing::run_test2(false, |cm, _handler| {
|
|
|
|
let fm = cm.new_source_file(FileName::Anon, "function foo(){ return 'I'; }".to_string());
|
|
|
|
let lexer = Lexer::new(
|
|
|
|
Default::default(),
|
|
|
|
EsVersion::latest(),
|
|
|
|
StringInput::from(&*fm),
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
|
|
|
|
let mut parser = Parser::new_from(lexer);
|
|
|
|
|
|
|
|
let m = parser.parse_module().unwrap();
|
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
m.visit_with(&mut All {
|
|
|
|
visitor: Issue1967 {},
|
|
|
|
});
|
2021-08-14 21:34:14 +03:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.unwrap();
|
|
|
|
}
|