fix(codegen): #1008 — recognize post-#973 globalThis.Promise shape#1009
Merged
Conversation
PR #973 lowered bare built-in idents (`Promise`, `Array`, `Date`, ...) as `PropertyGet { GlobalGet(0), name }` so they route through the globalThis singleton closure path. Two codegen call sites that specialize `.then()` dispatch were still pattern-matching the legacy `Expr::GlobalGet(_)` shape only: - `type_analysis::is_promise_expr` for `Promise.resolve/reject/all/race/ allSettled/any(...)` and `Array.fromAsync(...)`. - `lower_call.rs`'s fused `Promise.resolve(x).then(cb)` fast path that routes to `js_promise_resolved_then`. When `is_promise_expr` returned false, `.then(cb)` fell through to the generic native method dispatch which doesn't enqueue the callback — microtask-02..07 and edge-promises went silent in compile-smoke's Native no-fallback gate, and on Linux V8 surfaced the same shape as `TypeError: then is not a function`. The Native gate had been red on every PR since #973 (admin-bypassed on #997 / #1000 / #1003 / #1004). Extract `type_analysis::is_global_builtin_named(expr, name)` that matches both shapes (legacy `GlobalGet(_)` and the post-#973 `PropertyGet { GlobalGet(0), name }`) and route both call sites through it. Validation: `scripts/run_native_no_fallback_tests.sh` — 35 passed, 0 failed (was 28/7 pre-fix).
This was referenced May 18, 2026
proggeramlug
added a commit
that referenced
this pull request
May 18, 2026
Both PRs were admin-merged with lint red. Land the trivial fmt cleanup so subsequent PRs don't inherit the lint failure on top of their own diffs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1008.
Summary
PR #973 changed bare built-in idents (
Promise,Array,Date, ...)to lower as
PropertyGet { GlobalGet(0), <name> }so they route throughthe
globalThissingleton closure path. Two codegen call sites thatspecialize
.then()dispatch were still pattern-matching the legacyExpr::GlobalGet(_)shape only:type_analysis::is_promise_exprforPromise.resolve/reject/all/race/ allSettled/any(...)andArray.fromAsync(...).lower_call.rs's fusedPromise.resolve(x).then(cb)fast path thatroutes to
js_promise_resolved_then.When
is_promise_exprreturned false,.then(cb)fell through to thegeneric native method dispatch which doesn't enqueue the callback —
microtask-02..07 and edge-promises went silent in compile-smoke's
Native no-fallback gate, and on Linux V8 surfaced the same shape asTypeError: then is not a function. The Native gate has been red onevery PR since #973 (admin-bypassed for #997 / #1000 / #1003 / #1004).
Fix
Extract
type_analysis::is_global_builtin_named(expr, name)thatmatches both shapes:
Expr::GlobalGet(_)directly.Expr::PropertyGet { object: GlobalGet(0), property: <name> }.Route both
is_promise_exprand thelower_call.rsfused fast paththrough it. Two-line widening of the predicate; behavior is otherwise
unchanged.
Test plan
native-no-fallback-tests: 28 passed, 7 failed(microtask-02..07 + edge-promises FAIL).native-no-fallback-tests: 35 passed, 0 failed.node --experimental-strip-types test-files/test_microtask_inv_02_then_vs_await_fifo.tsand the perry binary now produce the same output.Why merge fast
This unblocks every PR currently sitting behind a red
compile-smoke. Itis also the third stale-on-main blocker today after #958 (cargo-test
crypto rejection) and #1003 (api-docs-drift).