mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: interpolation calling twice fix
if string interpolation needs to call a function, it will cache the return to .len & .str usage in the generated code
This commit is contained in:
parent
5481f226dd
commit
96152510e5
@ -2907,7 +2907,9 @@ fn (p mut Parser) string_expr() {
|
||||
if is_array && !has_str_method {
|
||||
p.gen_array_str(typ2)
|
||||
}
|
||||
args = args.all_before_last(val) + '${typ}_str(${val}).len, ${typ}_str(${val}).str'
|
||||
tmp_var := p.get_tmp()
|
||||
p.cgen.insert_before('string $tmp_var = ${typ}_str(${val});')
|
||||
args = args.all_before_last(val) + '${tmp_var}.len, ${tmp_var}.str'
|
||||
format += '%.*s '
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user