diff --git a/vlib/v/gen/c/comptime.v b/vlib/v/gen/c/comptime.v index 2d3affdefd..e0d54527c3 100644 --- a/vlib/v/gen/c/comptime.v +++ b/vlib/v/gen/c/comptime.v @@ -159,11 +159,7 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) { } } } - if g.inside_call { - g.write(')') - } else { - g.write(');') - } + g.write(')') return } mut j := 0 diff --git a/vlib/v/tests/comptime_method_call_test.v b/vlib/v/tests/comptime_method_call_test.v new file mode 100644 index 0000000000..6c927f56f7 --- /dev/null +++ b/vlib/v/tests/comptime_method_call_test.v @@ -0,0 +1,25 @@ +struct App {} + +fn (mut app App) method_one() string { + return '1' +} + +fn (mut app App) method_two() string { + return '2' +} + +fn reflect_call(method_name string) string { + a := App{} + $for method in App.methods { + if method.name == method_name { + return a.$method() + '' + } + } + panic('Method not supported: $method_name') +} + +fn test_comptime_method_call() { + result := reflect_call('method_one') + println(result) + assert result == '1' +}