E0086: interpolation_format_spec
E0086 interpolation_format_spec — a format spec in an interpolation (use format()).
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0086).
The rule
Soma interpolations take no format spec, so {total:.2f} would print literally; check refuses it. Format the value with a builtin: {to_fixed(total, 2)}, or let s = format("%.2f", total) and then {s}.
A program that triggers it
wrong.cell
cell Receipt {
on summary(customer: String, total: Float) {
return "{customer} owes {total:.2f} EUR"
}
}What soma check prints:
$ soma check wrong.cell
error: string interpolation `{total:.2f}` has a Python format spec — Soma has none, so it would print literally; format the value: `{to_fixed(total, 2)}` (printf-style: `let s = format("%.2f", total)`, then `{s}`)
--> wrong.cell:3:16
|
3 | return "{customer} owes {total:.2f} EUR"
| ^
= code: E0086
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: Soma has none, so it would print literally; format the value: `{to_fixed(total, 2)}` (printf-style: `let s = format("%.2f", total)`, then `{s}`)
The fix
On line 3, return "{customer} owes {total:.2f} EUR" becomes return "{customer} owes {to_fixed(total, 2)} EUR".
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
cell Receipt {
on summary(customer: String, total: Float) {
- return "{customer} owes {total:.2f} EUR"
+ return "{customer} owes {to_fixed(total, 2)} EUR"
}
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.