clockworklabs / clockworklabs/SpacetimeDB
Rust reducers must disallow reducers starting with reserved prefix
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 25.2k
- Forks
- 1.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 46
Description
The API proposal states:
Reserved reducer names
We reserve all reducer names beginning with two underscores
__, and withonorOn. Double-underscore reducer names are used internally to implement built-in reducers, and on/On are used in SDK codegen for reducer callbacks.Attempting to define a reducer with a name that matches these patterns will cause an error at macro-expand time. Implementors are also encouraged to signal an error at publish time if a module circumvents the bindings library and manually constructs a ModuleDef containing one of these names in a reserved position.
Those are rejected in C# as per proposal, but not in Rust. In fact, rust-wasm-test actually defines such a reducer that should be illegal now:
and in generated TS code it ends up looking as OnOnConnect event.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start with the reserved reducer proposal and the reducer definition at modules/rust-wasm-test/src/lib.rs#L241-L242, then trace Rust macro expansion and validation. Ensure names beginning with __, on, or On are rejected at macro-expand time, and verify the generated TypeScript no longer produces names such as OnOnConnect.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, typescript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100