E1062: guard needs more than read-only access
A guard is written Pattern if condition => body.
A guard is written Pattern if condition => body. It decides whether a
branch applies, so it may only look at values (ADR-0016). It cannot move or
change a resource while it decides. A guard may call a verb whose
parameters are all abs, because such a call only reads. The compiler rejects
a guard that calls any other verb (one with an erg, dat or ins
parameter), builds a struct, indexes an array or contains a
case or an if, and a guard that reads a binding that is no longer live.
The message names the call, the name or the construct, and states the rule: a
guard may read bindings and call verbs whose parameters are all abs; bind
anything else before the case. The error points at it.
Example
Fix
Call only a verb whose parameters are all abs, write the test with
operators on bindings and literals, or compute it before the case and name it
with a binding.
Run actus explain E1062 in your terminal to read this entry offline. Browse Ownership & types or all error codes.