You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
textfieldGetString return value corrupted when stored in local variable #10
textfieldGetString() returns a NaN-boxed string correctly at the native level (verified via Rust debug prints), but the value becomes undefined when used from TypeScript.
Root Cause Analysis
The Rust get_string_value() function correctly reads the NSTextField value and returns it via js_string_from_bytes + js_nanbox_string. The NaN-boxed f64 is valid.
However, when the result is stored in a const variable that the codegen marks as is_string, the codegen:
Extracts the raw i64 pointer from the NaN-box (since is_string locals are stored as i64)
Later, when the variable is passed to encodeURIComponent() or used in ||, the i64 is not re-NaN-boxed
This causes:
|| operator: js_is_truthy receives the raw i64 interpreted as f64, which is NaN → always falsy
encodeURIComponent(): receives garbage value → produces "undefined"
Reproduction
import{TextField,textfieldGetString}from'perry/ui';constfield=TextField('',(val: string)=>{});// User types "hello" in the fieldconstbtn=Button('Test',()=>{constraw=textfieldGetString(field);// raw.length works (inline string length access on i64 pointer)// typeof raw === 'string' works (compile-time constant)// But encodeURIComponent(raw) produces "undefined"// And (raw || 'fallback') always returns 'fallback'});
Observations
name/host/port fields work because their variables are used in string concatenation (+) which the codegen handles with string-aware code
user/pass fields fail because they're passed to encodeURIComponent() which expects f64 NaN-boxed values
The typeof x === 'string' && x.length > 0 check passes (both are inlined by codegen) but the VALUE is still corrupted when used as an argument to other functions
Pinning the GC allocation doesn't help — the string data is intact, but the NaN-boxing is stripped
Expected Fix
When an is_string local (stored as i64) is passed to a generic function that expects f64, the codegen should re-NaN-box it via js_nanbox_string(ptr).
Activity
Fix connection form: use string concat workaround for Perry NaN-boxin…