Skip to content

Commit

Permalink
Fix order of ToString call in Function constructor (#3820)
Browse files Browse the repository at this point in the history
The `ToString` method was being called on the body before the paramater
list, this caused some test262 tests to fail.
  • Loading branch information
HalidOdat authored Apr 18, 2024
1 parent 5a4d977 commit 261e264
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
// 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())
Expand Down

0 comments on commit 261e264

Please sign in to comment.