mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-09 14:53:16 +08:00
The stream completion closures carried SCR_CLOSURE_KIND_RECEIVER_FREE, so compiled callers skipped the receiver bracket around cb(). A completion runs user code synchronously (the write(chunk, callback) callback, the next queued _write), and that code reads the ambient receiver, so the flag is removed and the completions bind `this` as any unbound call does. Corpus programs 8531 and 8532 call a saved completion from inside another object's method, from JavaScript and from a TypeScript class method that JavaScript calls, and check `this` in the callbacks it runs against Node.