mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: fix comptime method call (#15279)
This commit is contained in:
parent
b6ce7cc198
commit
e6a04905e9
@ -1841,13 +1841,15 @@ pub fn (mut f Fmt) comptime_call(node ast.ComptimeCall) {
|
||||
} else {
|
||||
'${node.method_name}($inner_args)'
|
||||
}
|
||||
f.write('${node.left}.$$method_expr')
|
||||
f.expr(node.left)
|
||||
f.write('.$$method_expr')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut f Fmt) comptime_selector(node ast.ComptimeSelector) {
|
||||
f.write('${node.left}.\$($node.field_expr)')
|
||||
f.expr(node.left)
|
||||
f.write('.\$($node.field_expr)')
|
||||
}
|
||||
|
||||
pub fn (mut f Fmt) concat_expr(node ast.ConcatExpr) {
|
||||
|
15
vlib/v/fmt/tests/comptime_method_call_keep.vv
Normal file
15
vlib/v/fmt/tests/comptime_method_call_keep.vv
Normal file
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
struct Dummy {}
|
||||
|
||||
fn (d Dummy) sample(x int) int {
|
||||
return x + 1
|
||||
}
|
||||
|
||||
fn main() {
|
||||
$for method in Dummy.methods {
|
||||
if os.args.len > 1 {
|
||||
Dummy{}.$method(os.args[1].int())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user