Home / Docs / Diagnostics
U0006: Text literal inside interpolation
Release v0.4.0
Interpolation embeds an expression in a text literal, as in "seats {e.remaining}" (spec/01 §6). The embedded expression must not contain another text literal, which keeps every literal on one level and easy to read and edit. Bind the inner text with let and interpolate the name instead.
The repair at a glance
diff
module demo
- pub greeting() -> Text = "hello {trim(" world ")}"
+ pub greeting() -> Text
+ =
+ let name = trim(" world ")
+ "hello {name}"Failing example
una
module demo
pub greeting() -> Text = "hello {trim(" world ")}"Fixed example
una
module demo
pub greeting() -> Text
=
let name = trim(" world ")
"hello {name}"