mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
fix(es/parser): Allow initializer of the var of for-in loop in non-strict mode (#5038)
This commit is contained in:
parent
8577caf535
commit
f238093c3b
@ -1130,7 +1130,7 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
self.emit_err(d.name.span(), SyntaxError::TooManyVarInForInHead);
|
||||
}
|
||||
} else {
|
||||
if decl.decls[0].init.is_some() {
|
||||
if (self.ctx().strict || is!(self, "of")) && decl.decls[0].init.is_some() {
|
||||
self.emit_err(
|
||||
decl.decls[0].name.span(),
|
||||
SyntaxError::VarInitializerInForInHead,
|
||||
|
@ -353,3 +353,8 @@ fn illegal_language_mode_directive2() {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_non_strict_for_loop() {
|
||||
script("for (var v1 = 1 in v3) {}");
|
||||
}
|
||||
|
@ -104,6 +104,8 @@ fn add_test<F: FnOnce() + Send + 'static>(
|
||||
#[cfg(feature = "verify")]
|
||||
fn error_tests(tests: &mut Vec<TestDescAndFn>) -> Result<(), io::Error> {
|
||||
const IGNORED_ERROR_TESTS: &[&str] = &[
|
||||
// pass in script. error in module.
|
||||
"e3fbcf63d7e43ead.js",
|
||||
// Old (wrong) tests
|
||||
"569a2c1bad3beeb2.js",
|
||||
"3b6f737a4ac948a8.js",
|
||||
|
Loading…
Reference in New Issue
Block a user