ErrorsReads and writes · rule
data.write_before_call
Write comes before a later outside call.
Area 6, Reads and writes; not declinable; the next step is usually the agent's.
No transaction is open while an outside call is out, so an action's writes come after its last call ("Several outside calls"). The error is at the write, naming the last call it comes before; one made through an action it calls names that action and the call it makes:
use app { sheets }use bakery/entities { PriceSheet }use bakery/types { SheetText }use bakery/failures { SheetNotKept }/// Marks a supplier's price sheet checked, then keeps the sheet they sent/// again: the write comes before the call.action recheck_prices( price_sheet: PriceSheet, sheet_text: SheetText) fails SheetNotKept -> PriceSheet { var checked: PriceSheet = PriceSheet.update(price_sheet) { set: { checked: true } } var sheet: File = attempt sheets.put(encoding.to_utf8(sheet_text), FileType.csv) { storage_full: SheetNotKept } return PriceSheet.update(checked) { set: { sheet: sheet } }}
error PriceSheet.update writes before the call to sheets.put
--> domains/bakery/actions/recheck_prices.jadpo:12:31
|12 | var checked: PriceSheet = PriceSheet.update(price_sheet) { | ^^^^^^^^^^^^^^^^^ writes here17 | var sheet: File = attempt sheets.put(encoding.to_utf8(sheet_text), FileType.csv) { | ---------- the call it must follow
- reason
- No transaction is open while an outside call is out, so an action writes only after its last call; run as written,
sheets.putwould be refused. - next
- Move
PriceSheet.updateaftersheets.put(agent) - rule
- data.
write_ before_ call - help
- https://jadpo.
dev/docs/errors/data. write_ before_ call
Markdown for agents: /docs/errors/data.write_before_call.md.Built from Jadpo main at aee2e8f.