fmt: fix string interpolation with CastExpr (#9137)

pull/9168/head
Lukas Neubert 2021-03-06 19:47:19 +01:00 committed by GitHub
parent ce92bf8da0
commit 043c29cf95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -162,6 +162,8 @@ pub fn (lit &StringInterLiteral) get_fspec_braces(i int) (string, bool) {
} else if sub_expr.left is CallExpr { } else if sub_expr.left is CallExpr {
sub_expr = sub_expr.left sub_expr = sub_expr.left
continue continue
} else if sub_expr.left is CastExpr {
needs_braces = true
} }
break break
} }

View File

@ -11,4 +11,5 @@ fn main() {
eprintln('e: $e') eprintln('e: $e')
_ = ' ${foo.method(bar).str()} ' _ = ' ${foo.method(bar).str()} '
println('(${some_struct.@type}, $some_struct.y)') println('(${some_struct.@type}, $some_struct.y)')
_ := 'CastExpr ${int(d.e).str()}'
} }