Skip to content

Commit 82c6d88

Browse files
committed
Refine the warning about effects dependency cycles to explicitly point out that this issue may lead to infinite loops or unresolvable conflicts, and emphasize that developers need to manually ensure that effects do not update signals in their dependency chain.
1 parent 9182184 commit 82c6d88

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

macros/src/lib.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@ use syn::{Expr, Ident, ItemFn, ItemStatic, ReturnType, parse_macro_input};
3939
/// # Warning
4040
///
4141
/// **Do not set any signal that is part of the same effect chain.**
42-
/// Doing so will trigger infinite recursion or panic due to RefCell borrow conflicts.
42+
///
43+
/// Effects automatically run whenever one of their dependent signals changes.
44+
/// If an effect modifies a signal that it (directly or indirectly) observes,
45+
/// it creates a circular dependency. This can lead to:
46+
/// - an infinite loop of updates, or
47+
/// - conflicting updates that the system cannot resolve.
48+
///
49+
/// In the general case, it is impossible to automatically determine whether
50+
/// such an effect will ever terminate—this is essentially a version of the
51+
/// halting problem. Therefore, you must ensure manually that effects do not
52+
/// update signals within their own dependency chain.
4353
#[proc_macro]
4454
pub fn signal(input: TokenStream) -> TokenStream {
4555
let item = parse_macro_input!(input as ItemStatic);
@@ -234,7 +244,17 @@ pub fn memo(_attr: TokenStream, item: TokenStream) -> TokenStream {
234244
/// # Warning
235245
///
236246
/// **Do not set any signal that is part of the same effect chain.**
237-
/// Doing so will trigger infinite recursion or panic due to RefCell borrow conflicts.
247+
///
248+
/// Effects automatically run whenever one of their dependent signals changes.
249+
/// If an effect modifies a signal that it (directly or indirectly) observes,
250+
/// it creates a circular dependency. This can lead to:
251+
/// - an infinite loop of updates, or
252+
/// - conflicting updates that the system cannot resolve.
253+
///
254+
/// In the general case, it is impossible to automatically determine whether
255+
/// such an effect will ever terminate—this is essentially a version of the
256+
/// halting problem. Therefore, you must ensure manually that effects do not
257+
/// update signals within their own dependency chain.
238258
#[proc_macro]
239259
pub fn effect(input: TokenStream) -> TokenStream {
240260
let expr = parse_macro_input!(input as Expr);

0 commit comments

Comments
 (0)