Commit Graph
4 Commits
Author SHA1 Message Date
dotCooCoo c0b4413a5a JS: fix async function review points
- AsyncFunction.prototype has Symbol.toStringTag "AsyncFunction",
  configurable only.
- await checks the room for the awaited promise's reaction or job and
  the suspended frame's bytes before it attaches the reaction, so a
  suspension stays within the heap limit.
- An async function's return pops its frame before resolving its
  promise, so a then getter on the returned value runs without it.
  Returning the function's own promise rejects it at the return.
- Block functions whose variable was not declared are kept in a hash
  set, so each block function's lookup takes constant time.
- A shorthand await in an object pattern of an async arrow function's
  head is a syntax error, and the head accepts patterns with defaults
  such as async ({a = 1}) => a. async({a = 1}) without an arrow is
  still a syntax error.
- docs: .jsx files and source strings run with module: true have
  Promise and the async syntax; await is an identifier only in script
  code.
2026-12-02 08:30:09 -08:00
dotCooCoo 3d063a486a Merge main into feat/js-es2017-async-await
Async function activations now save and restore this_in_env, strict_class, new_target and this_env with main's Frame fields. The string spread test sets its fuel above what main's iterator-based spread takes.
2026-11-28 20:09:17 -08:00
dotCooCoo b900ea2308 JavaScript: a block function skips its variable when a let has the name
- A block function in script or eval code no longer stops the run with
  "redeclaration of" when a `let`, a `const` or a block function between
  the code and its variable environment has its name, or when the global
  object cannot take the variable (Annex B.3.3.2 and B.3.3.3). Its block
  still has the function, and a `var` of the name is still a SyntaxError.
- A script stopped by the heap limit or the frame limit declares none of
  its `let` and `const` names, so a later script can declare them. The
  frame limit is checked, and the heap reserved for the names, before
  anything is declared.
- An arrow function in an async arrow function's parameters reads `await`
  as an identifier, as its own body does.
- With E4X, `async::name` is a qualified name.
- `AsyncFunction` inherits from the built-in `Function` even after a
  script replaced `Function.prototype.constructor`.
- The test262 reports list the older edition's panics, an async test
  passes only when one `print` call gives exactly the completion line,
  and the promise collection test checks that all 200 rejections arrive.
2026-11-22 13:56:10 -08:00
dotCooCoo ab12c44ebd JavaScript: .js scripts run async functions and await
A .js script now reads async function declarations and expressions, async
arrow functions and async methods in object literals, as ECMA-262 2017
section 25.5 defines them. A call returns a Promise that the function's
return resolves and an uncaught exception rejects. await suspends the
function's frame until its operand settles; a promise job resumes it with
the value, or throws the rejection at the await, so try, catch and finally
work around it.

- Options::es2017 turns the syntax on and implies Options::es2015;
  script.run sets it for .js files. .jsx scripts and source strings keep
  async and await as plain names.
- A suspended frame is a heap object the collector traces, reached only
  from its promise reactions, so a function waiting on a promise that
  nothing can settle is freed. Each resume is a job and takes fuel.
- AsyncFunction and its prototype exist without a global binding; async
  functions are not constructors and have no prototype property.
- The test262 runner reads the async-function, await and async-arrow
  folders and counts runs with and without the option; an async test with
  a runtime negative now has to throw.
2026-11-22 08:59:26 -08:00