#2836

Hoisted TextEncoder feature probe returns false for encodeInto

Openjlucaso1opened 11d ago

A hoisted var holding a TextEncoder reports an existing prototype method as absent. This executes wasm-bindgen's fallback assignment and throws a deferred SC1090 before WASM initialization.

var encoder = new TextEncoder;
console.log("encodeInto" in encoder);
if (!("encodeInto" in encoder)) encoder.encodeInto = function () {};
console.log("ready");

Node 24.22.1 prints true and ready, exit 0. Scriptc main 5989ca7ed and #2149 head 5ae71eafa compile the program, but the native binary prints false and throws assignment to non-variables ... [SC1090], exit 1.

The frontend retains an undefined arm for hoisted var storage. The in lowering's union-record path checks internal brand-record fields instead of the builtin prototype members. The non-union brand-record path already recognizes those members. The undefined arm must still throw TypeError if it is actually selected.

This is the current offline bridge initialization blocker in https://github.com/oxidezap/baileyrs/pull/176#issuecomment-6562285500, using @oxidezap/whatsapp-rust-bridge 0.26.4. Its wasm-bindgen glue contains the same encodeInto feature probe. No WhatsApp connection is needed.

Related work checked: #1625 concerns non-null asserted assignments and is closed; #2512 intentionally preserves the codec expando refusal; #2724 concerns imported type mapping; #2780 adds own-property tables for handles; #2834 covers intrinsic objects. This report concerns the incorrect in result, not implementing member replacement or removing the polyfill. A focused frontend fix and differential regression are in progress.

Activity

0

No activity yet.