1
0
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:
yuyi 2022-07-30 19:28:34 +08:00 committed by GitHub
parent b6ce7cc198
commit e6a04905e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -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) {

View 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())
}
}
}