mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
allow return outside function instead of needlessly logging an error
This commit is contained in:
parent
8b62493bcc
commit
4efb930c20
1 changed files with 8 additions and 2 deletions
|
@ -15,7 +15,7 @@ use oxc::{
|
||||||
Visit,
|
Visit,
|
||||||
},
|
},
|
||||||
diagnostics::OxcDiagnostic,
|
diagnostics::OxcDiagnostic,
|
||||||
parser::Parser,
|
parser::{ParseOptions, Parser},
|
||||||
span::{Atom, GetSpan, SourceType, Span},
|
span::{Atom, GetSpan, SourceType, Span},
|
||||||
syntax::operator::{AssignmentOperator, UnaryOperator},
|
syntax::operator::{AssignmentOperator, UnaryOperator},
|
||||||
};
|
};
|
||||||
|
@ -420,7 +420,13 @@ fn random_string() -> String {
|
||||||
pub fn rewrite(js: &str, url: Url, config: Config) -> Result<(Vec<u8>, Vec<OxcDiagnostic>)> {
|
pub fn rewrite(js: &str, url: Url, config: Config) -> Result<(Vec<u8>, Vec<OxcDiagnostic>)> {
|
||||||
let allocator = Allocator::default();
|
let allocator = Allocator::default();
|
||||||
let source_type = SourceType::default();
|
let source_type = SourceType::default();
|
||||||
let ret = Parser::new(&allocator, js, source_type).parse();
|
let ret = Parser::new(&allocator, js, source_type)
|
||||||
|
.with_options(ParseOptions {
|
||||||
|
parse_regular_expression: false, // default
|
||||||
|
allow_return_outside_function: true,
|
||||||
|
preserve_parens: true, // default
|
||||||
|
})
|
||||||
|
.parse();
|
||||||
|
|
||||||
let program = ret.program;
|
let program = ret.program;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue