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
LLVM codegen: FetchGetWithAuth and DateToLocaleString expressions not lowered (regression vs v0.5.491) #600
The LLVM Phase 2 codegen backend (default in current perry) doesn't lower two expression node kinds that are otherwise wired up across HIR, JS codegen, WASM codegen, and type analysis. This regressed between v0.5.491 (compiles fine) and v0.5.696 (current HEAD b6c3afc1).
Errors
Error compiling module 'lib/gsc/client.ts' with --backend llvm:
lowering closure func_id=35: lowering closure body func_id=35:
perry-codegen Phase 2: expression FetchGetWithAuth not yet supported
Error compiling module 'lib/notifications/scheduler.ts' with --backend llvm:
lowering function 'processUserNotification':
lowering body of 'processUserNotification':
perry-codegen Phase 2: expression DateToLocaleString not yet supported
Minimal repros
FetchGetWithAuth (any use of the recognized fetchWithAuth built-in):
But neither expression has an arm in the LLVM codegen (crates/perry-codegen/src/expr.rs, codegen.rs):
$ grep -n "FetchGetWithAuth\|DateToLocaleString" crates/perry-codegen/src/expr.rs crates/perry-codegen/src/codegen.rs
(no matches)
So they fall through to the "expression … not yet supported" arm in Phase 2 lowering.
Impact
Any TS source using either pattern can no longer be compiled with the default LLVM backend. In our case, this affects the production gscmaster.com API — fetchWithAuth/fetchPostWithAuth are documented as the recommended way to call authenticated HTTP endpoints (because regular fetch() silently drops headers from variables, known perry quirk), and .toLocaleString() is used for formatting numbers in notification emails.
Suggested fix
Implement the two expression arms in crates/perry-codegen/src/expr.rs. The JS codegen at emit.rs:1717-1722 (FetchGetWithAuth) and :2155 (DateToLocaleString) are concise semantic references:
DateToLocaleString(n) → emit a runtime helper that formats a number with locale-specific thousands separators (matches JS behavior of (12345).toLocaleString() === "12,345" in en-US)
Happy to test a fix against the gscmaster API codebase if helpful.
Activity