Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust reducers must disallow reducers starting with reserved prefix #2175

Open
RReverser opened this issue Jan 27, 2025 · 0 comments
Open

Rust reducers must disallow reducers starting with reserved prefix #2175

RReverser opened this issue Jan 27, 2025 · 0 comments

Comments

@RReverser
Copy link
Contributor

The API proposal states:

Reserved reducer names

We reserve all reducer names beginning with two underscores __, and with on or On. 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:

#[spacetimedb::reducer(client_connected)]
fn on_connect(_ctx: &ReducerContext) {}

and in generated TS code it ends up looking as OnOnConnect event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant