Rust codegen: Non-function properties on @ExportProxy or @ExportModule fail at runtime due to unconditional function dispatch

Aperta
#251 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp, rust, typescript
Ambito
api, backend

Direzione di ricerca

Start with compiler/compiler/Compiler/Sources/Generation/Rust/RustMethodResolver.swift and trace how RustProxyGenerator and RustModuleGenerator handle resolved entries; then inspect RustSchemaWriter.appendInterface and the proxy and module registration paths in RustValdi.cpp. Check how generated JS-backed proxy getters and Rust-implemented proxy or module values match their schema slots. Done means non-function properties are read as values or rejected consistently, with runtime dispatch matching the schema.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.

Non-function properties on @ExportProxy or @ExportModule fail at runtime due to unconditional function dispatch

File: compiler/compiler/Compiler/Sources/Generation/Rust/RustMethodResolver.swift

When a TypeScript @ExportProxy interface declares a non-function property (such as a readonly field), calling the generated Rust getter on a JS-backed proxy fails at runtime, and passing a Rust-implemented proxy to JS puts a function object in a non-function schema slot. The mismatch starts in RustMethodResolver.resolve, where the default: branch lowers non-function properties into zero-parameter RustResolvedMethod entries while RustProxyGenerator still emits function-call dispatch for every resolved method.

For a JS-backed proxy, the generated borrowedMethods implementation fetches the property via self.0.property(...), deserializes it as valdi_core_rust::FunctionRef<'_>, and invokes call_with, which fails because the JS value is not a function; for a Rust-implemented proxy (or @ExportModule), RustSchemaWriter.appendInterface emits a non-function schema field while valdi_rust_value_new_proxy / valdi_rust_register_module in RustValdi.cpp populates every slot with a RustModuleMethod function.

Separate non-function properties from methods in RustMethodResolver.resolve (for instance with an isMethod flag) so RustProxyGenerator reads value properties directly via ValdiDeserialize on JS proxies and RustProxyGenerator / RustModuleGenerator either disallow non-function properties or expose a property-read path that matches the schema.

Lingua principale
C++
Stelle
16.4k
Fork
539
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Snapchat/Valdi

Tutte le issue di Snapchat/Valdi

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.