E4096

E4096#

字符串插值语法不能用于创建 Bytes 类型的值,只能用于创建 String 类型的值。

错误示例#

test {
  let x : Int = 42
  let _ : Bytes = "(\{x})"
}

建议#

如果需要动态地创建类型为 Bytes 的值,可以使用 @buffer.T 类型:

test {
  let x : Int = 42
  let buf = @buffer.new()
  let _ : Bytes = buf
    ..write_string("(")
    ..write_object(x)
    ..write_string(")")
    .to_bytes()
}