Browse Source

Fix order of `ToString` call in Function constructor (#3820)

The `ToString` method was being called on the body before the paramater
list, this caused some test262 tests to fail.
pull/3821/head
Haled Odat 8 months ago committed by GitHub
parent
commit
261e264b01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      core/engine/src/builtins/function/mod.rs

11
core/engine/src/builtins/function/mod.rs

@ -436,15 +436,18 @@ impl BuiltInFunctionObject {
// 6. Let argCount be the number of elements in parameterArgs.
let (body, param_list) = if let Some((body, params)) = args.split_last() {
// 7. Let bodyString be ? ToString(bodyArg).
let body = body.to_string(context)?;
// 8. Let parameterStrings be a new empty List.
// 7. Let parameterStrings be a new empty List.
let mut parameters = Vec::with_capacity(args.len());
// 9. For each element arg of parameterArgs, do
// 8. For each element arg of parameterArgs, do
for param in params {
// a. Append ? ToString(arg) to parameterStrings.
parameters.push(param.to_string(context)?);
}
// 9. Let bodyString be ? ToString(bodyArg).
let body = body.to_string(context)?;
(body, parameters)
} else {
(js_string!(), Vec::new())

Loading…
Cancel
Save