E0084: interpolation_trailing
E0084 interpolation_trailing — text after the expression of an interpolation.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0084).
The rule
An interpolation {...} must hold exactly one expression. In {total - fee cents} the word cents is a second expression, and the message says that part would be dropped. Close the brace after the expression and keep the text outside it, or bind the value with a let first.
A program that triggers it
wrong.cell
cell Receipt {
on summary(customer: String, total: Int, fee: Int) {
return "{customer} owes {total - fee cents}"
}
}What soma check prints:
$ soma check wrong.cell
error: string interpolation `{total - fee cents}` is not one expression — the part after it would be dropped; bind it with a let first
--> wrong.cell:3:16
|
3 | return "{customer} owes {total - fee cents}"
| ^
= code: E0084
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: the part after it would be dropped; bind it with a let first
The fix
On line 3, return "{customer} owes {total - fee cents}" becomes return "{customer} owes {total - fee} cents".
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
cell Receipt {
on summary(customer: String, total: Int, fee: Int) {
- return "{customer} owes {total - fee cents}"
+ return "{customer} owes {total - fee} cents"
}
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.