ladybird/Userland/Libraries/LibJS/Tests/functions
Linus Groh cf168fac50 LibJS: Implement [[Call]] and [[Construct]] internal slots properly
This patch implements:

- Spec compliant [[Call]] and [[Construct]] internal slots, as virtual
  FunctionObject::internal_{call,construct}(). These effectively replace
  the old virtual FunctionObject::{call,construct}(), but with several
  advantages:
  - Clear and consistent naming, following the object internal methods
  - Use of completions
  - internal_construct() returns an Object, and not Value! This has been
    a source of confusion for a long time, since in the spec there's
    always an Object returned but the Value return type in LibJS meant
    that this could not be fully trusted and something could screw you
    over.
  - Arguments are passed explicitly in form of a MarkedValueList,
    allowing manipulation (BoundFunction). We still put them on the
    execution context as a lot of code depends on it (VM::arguments()),
    but not from the Call() / Construct() AOs anymore, which now allows
    for bypassing them and invoking [[Call]] / [[Construct]] directly.
    Nothing but Call() / Construct() themselves do that at the moment,
    but future additions to ECMA262 or already existing web specs might.
- Spec compliant, standalone Call() and Construct() AOs: currently the
  closest we have is VM::{call,construct}(), but those try to cater to
  all the different function object subclasses at once, resulting in a
  horrible mess and calling AOs with functions they should never be
  called with; most prominently PrepareForOrdinaryCall and
  OrdinaryCallBindThis, which are only for ECMAScriptFunctionObject.

As a result this also contains an implicit optimization: we no longer
need to create a new function environment for NativeFunctions - which,
worth mentioning, is what started this whole crusade in the first place
:^)
2021-10-09 14:29:20 +01:00
..
arrow-functions.js LibJS: Implement [[Call]] and [[Construct]] internal slots properly 2021-10-09 14:29:20 +01:00
constructor-basic.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-default-parameters.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-destructuring-parameters.js LibJS: Add tests for destructuring assignments and function parameters 2021-05-29 23:02:23 +04:30
function-duplicate-parameters.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-evaluation-order.js LibJS: Evaluate function arguments before checking callee type 2021-09-13 17:44:08 +01:00
function-hoisting.js LibJS: Improve function hoisting across blocks 2021-07-06 00:15:37 +01:00
function-length.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-missing-arg.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-name.js LibJS: Make scoping follow the spec 2021-09-30 08:16:32 +01:00
function-nesting.js LibJS: Ensure function declarations don't leak outside function scopes 2021-05-13 23:59:00 +01:00
function-new-target.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-prototype-writable.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-rest-params.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-spread.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-strict-mode.js LibJS: Fix functions binding this to global object in strict mode 2021-06-04 13:00:37 +01:00
function-this-in-arguments.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
function-TypeError.js Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00