Browse Source

Always return `undefined` from functions that do not `return` (#1528)

pull/1536/head
raskad 3 years ago committed by GitHub
parent
commit
4464a8cc5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      boa/src/builtins/json/tests.rs
  2. 5
      boa/src/object/gcobject.rs

5
boa/src/builtins/json/tests.rs

@ -336,8 +336,9 @@ fn json_parse_array_with_reviver() {
if (typeof v == 'number') {
return v * 2;
} else {
v
}})"#,
return v;
}
})"#,
)
.unwrap();
assert_eq!(

5
boa/src/object/gcobject.rs

@ -327,8 +327,11 @@ impl JsObject {
// 14. Return ? constructorEnv.GetThisBinding().
this
} else {
} else if context.executor().get_current_state() == &InterpreterState::Return {
result
} else {
result?;
Ok(JsValue::undefined())
}
}
}

Loading…
Cancel
Save