Skip to content

fix(runtime): Promise resolving-functions [[AlreadyResolved]] guard + combinators#4745

Merged
proggeramlug merged 1 commit into
mainfrom
bi-promise-parity
Jun 7, 2026
Merged

fix(runtime): Promise resolving-functions [[AlreadyResolved]] guard + combinators#4745
proggeramlug merged 1 commit into
mainfrom
bi-promise-parity

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

What

Fixes built-ins/Promise (baseline 402/574, 70%) by modeling resolving-function semantics correctly.

Root causes

  1. Missing shared [[AlreadyResolved]] guard (ECMA-262 27.2.1.3 CreateResolvingFunctions). The resolve/reject pair given to an executor must share ONE boolean — once either fires, the other is a no-op, even while the promise is still pending (e.g. resolve(thenable) leaves the promise pending while the thenable job runs, but a later reject(x) must be ignored). The state != Pending check alone can't model this; added an explicit shared guard cell captured by both closures.
  2. Thenable assimilation / self-resolution. resolve now assimilates thenables/promises and rejects self-resolution.
  3. Combinator fixes in Promise.all/allSettled/race/any (combinators.rs).
  4. Closure capture reads are bounds-guarded so the optional shared-guard slot can be probed on closures allocated with fewer slots.

Files

promise/combinators.rs, promise/spec_combinators.rs, closure/alloc.rs

Delta confirmed by post-merge resweep. (No version/CHANGELOG bump — maintainer folds in.)

- Implement CreateResolvingFunctions (ECMA-262 27.2.1.3): the resolve/reject
  pair handed to an executor now share one [[AlreadyResolved]] cell, so once
  either fires the other is a no-op — even while the promise is still pending
  (resolve called with an unsettled thenable, then a later reject must be
  ignored). The state!=Pending check alone could not model this.
- resolve assimilates thenables/promises and rejects self-resolution.
- Promise.all/allSettled/race/any combinator fixes (combinators.rs).
- closure capture read is bounds-guarded so optional captures (the shared guard
  in slot 1) can be probed on closures allocated with fewer slots.
@proggeramlug proggeramlug merged commit e21c133 into main Jun 7, 2026
13 checks passed
@proggeramlug proggeramlug deleted the bi-promise-parity branch June 7, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant