mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: don't break indexing in string interpolation. (#10195)
This commit is contained in:
parent
7d210da9a5
commit
306c16f0fa
@ -180,7 +180,7 @@ pub fn (lit &StringInterLiteral) get_fspec_braces(i int) (string, bool) {
|
||||
} else if sub_expr.left is CallExpr {
|
||||
sub_expr = sub_expr.left
|
||||
continue
|
||||
} else if sub_expr.left is CastExpr {
|
||||
} else if sub_expr.left is CastExpr || sub_expr.left is IndexExpr {
|
||||
needs_braces = true
|
||||
}
|
||||
break
|
||||
|
@ -7,9 +7,11 @@ fn main() {
|
||||
b := 'xyz'
|
||||
e := 'a: $a b: $b i: $i'
|
||||
d := 'a: ${a:5s} b: ${b:-5s} i: ${i:20d}'
|
||||
f := 'a byte string'.bytes()
|
||||
println('a: $a $b xxx')
|
||||
eprintln('e: $e')
|
||||
_ = ' ${foo.method(bar).str()} '
|
||||
println('(${some_struct.@type}, $some_struct.y)')
|
||||
_ := 'CastExpr ${int(d.e).str()}'
|
||||
println('${f[0..4].bytestr()}')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user