mirror of
https://github.com/vlang/v.git
synced 2025-09-17 03:17:25 -04:00
cgen: fix comptime call in fn call (#13075)
This commit is contained in:
parent
7dc64de360
commit
5bc72c9c01
@ -150,7 +150,11 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.write(' ); // vweb action call with args')
|
if g.inside_call {
|
||||||
|
g.write(')')
|
||||||
|
} else {
|
||||||
|
g.write(');')
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mut j := 0
|
mut j := 0
|
||||||
|
29
vlib/v/tests/comptime_call_in_fn_call_test.v
Normal file
29
vlib/v/tests/comptime_call_in_fn_call_test.v
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
struct Foo {}
|
||||||
|
|
||||||
|
fn (f Foo) a() string {
|
||||||
|
return 'method_a'
|
||||||
|
}
|
||||||
|
|
||||||
|
fn (f Foo) b() string {
|
||||||
|
return 'method_b'
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_comptime_call_in_fn_call() {
|
||||||
|
f := Foo{}
|
||||||
|
|
||||||
|
mut rets := []string{}
|
||||||
|
|
||||||
|
$for method in Foo.methods {
|
||||||
|
x := f.$method()
|
||||||
|
println(x)
|
||||||
|
println(f.$method())
|
||||||
|
rets << get_string(f.$method())
|
||||||
|
}
|
||||||
|
assert rets.len == 2
|
||||||
|
assert rets[0] == 'method_a'
|
||||||
|
assert rets[1] == 'method_b'
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_string(s string) string {
|
||||||
|
return s
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user