error effects
What it means#
A function may call only functions whose effects are contained in its own effect set (§6.2). Effects of private functions are inferred, so the error appears where the set is fixed: a function that declares its effects (including pure), a pub(api) function, comptime code (§15.1), or a function-typed parameter.
Example#
fn calc() -> i32 pure {
sleep(1s) // <- effects (sleep needs `time`)
42
}error
effects
How to fix#
fn calc() -> i32 time {
sleep(1s)
42
}Add the missing effect to the signature, or remove the call. Effect-polymorphic helpers (effect F) let callers decide the set.