mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix cross assign with generic fn call (#18050)
This commit is contained in:
parent
28f85371b1
commit
e1e5076d94
@ -985,7 +985,10 @@ fn (mut g Gen) gen_cross_tmp_variable(left []ast.Expr, val ast.Expr) {
|
|||||||
g.write(')')
|
g.write(')')
|
||||||
}
|
}
|
||||||
ast.CallExpr {
|
ast.CallExpr {
|
||||||
fn_name := val.name.replace('.', '__')
|
mut fn_name := val.name.replace('.', '__')
|
||||||
|
if val.concrete_types.len > 0 {
|
||||||
|
fn_name = g.generic_fn_name(val.concrete_types, fn_name)
|
||||||
|
}
|
||||||
g.write('${fn_name}(')
|
g.write('${fn_name}(')
|
||||||
for i, arg in val.args {
|
for i, arg in val.args {
|
||||||
g.gen_cross_tmp_variable(left, arg.expr)
|
g.gen_cross_tmp_variable(left, arg.expr)
|
||||||
|
10
vlib/v/tests/cross_assign_with_generic_fn_call_test.v
Normal file
10
vlib/v/tests/cross_assign_with_generic_fn_call_test.v
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import math
|
||||||
|
|
||||||
|
fn test_cross_assign_with_generic_fn_call() {
|
||||||
|
mut x := -1
|
||||||
|
mut y := -2
|
||||||
|
x, y = y, math.abs(x)
|
||||||
|
println('${x} | ${y}')
|
||||||
|
assert x == -2
|
||||||
|
assert y == 1
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user