You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Module statics cannot hold string or struct types, which is the real limit on stateful handlers #562
Split out from the "capabilities are stateless" note in docs/effects-showcase.md. That note is broader than the actual limitation, and the two examples it gives both work today.
let mut seen: array<i32, 8> = [0, 0, 0, 0, 0, 0, 0, 0]
let mut n_seen: i32 = 0
collected 3: 10 20 30
Capability methods have no self, which is true, but Flow does have module statics and they are mutable from inside a handler. "A real collecting test-spy or a metrics counter" — the two cases the note names as impossible — are both straightforward.
What actually does not work
Module statics are restricted by type:
✗ Module static 'v' has unsupported type 'string': module statics must be a
primitive (i32/i64/u8/u32/f32/f64/c64/c128/bool), a fixed array of
primitives, or ptr<T>
Struct statics are rejected the same way. So a handler that accumulates strings or structs has nowhere to put them, and that is the real boundary. A spy collecting numbers is fine; a spy collecting log lines is not.
Suggested resolution
Either widen module statics to cover string and struct types, or keep the restriction and fix the documentation to describe it accurately. The current wording sends people to a more awkward pattern than they need for the common cases.
The documentation half is worth doing regardless of whether the restriction changes, since a stated limitation that is not real costs readers real work.
Reopening this with a concrete application use case. In EmbryoMaker Flow, batch execution state in src/model.flow is held in six module-level scalar globals. Grouping those related values into a ModelBatch record is rejected by flowc because module statics currently exclude struct types.
The batch API is used by the long-lived Studio server. A record would keep its token, target, mode, and elapsed progress together while preserving the existing API functions.
Could the Flow repo agent implement struct-typed module statics and open a follow-up patch PR against godofecht/embryo-maker-flow that groups this batch state into a record? Please preserve the current flowc build and simulation parity.
Activity
docs: correct three effects limitations that were broader than the tr…
Make every example in the expressions and matching chapter compile
Make every example in the expressions and matching chapter compile (#622
godofecht commentedon Oct 21, 2026
Reopening this with a concrete application use case. In EmbryoMaker Flow, batch execution state in
src/model.flowis held in six module-level scalar globals. Grouping those related values into aModelBatchrecord is rejected byflowcbecause module statics currently exclude struct types.The batch API is used by the long-lived Studio server. A record would keep its token, target, mode, and elapsed progress together while preserving the existing API functions.
Could the Flow repo agent implement struct-typed module statics and open a follow-up patch PR against
godofecht/embryo-maker-flowthat groups this batch state into a record? Please preserve the currentflowcbuild and simulation parity.Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Allow module statics of struct types
Closes #562
test(module-statics): retain struct and string regression on consolid…
fix(#562): reconcile static struct and string initialization with main