Rust codegen: Non-function properties on @ExportProxy or @ExportModule fail at runtime due to unconditional function dispatch
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp, rust, typescript
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C++
- Stars
- 16.4k
- Forks
- 539
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Snapchat/Valdi
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Rust codegen: RustMethodResolver fails to unwrap .nullable on optional interface/module methodsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
Similar issues
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialogPossibly taken @dpc00 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
throneproj/Throne#2227 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
Maintainers usually reply within 1 day