File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -4052,7 +4052,7 @@ fn (mut g Gen) return_stmt(node ast.Return) {
4052
4052
4053
4053
if node.exprs.len > 0 {
4054
4054
// skip `return $vweb.html()`
4055
- if node.exprs[0 ] is ast.ComptimeCall {
4055
+ if node.exprs[0 ] is ast.ComptimeCall && (node.exprs[ 0 ] as ast.ComptimeCall ).is_vweb {
4056
4056
g.expr (node.exprs[0 ])
4057
4057
g.writeln (';' )
4058
4058
return
Original file line number Diff line number Diff line change
1
+ struct App {}
2
+
3
+ fn (mut app App) method_one () string {
4
+ return '1'
5
+ }
6
+
7
+ fn (mut app App) method_two () string {
8
+ return '2'
9
+ }
10
+
11
+ fn reflect_call (method_name string ) string {
12
+ a := App{}
13
+ $for method in App.methods {
14
+ if method.name == method_name {
15
+ return a.$method ()
16
+ }
17
+ }
18
+ panic ('Method not supported: $method_name ' )
19
+ }
20
+
21
+ fn main () {
22
+ result := reflect_call ('method_one' )
23
+ println (result)
24
+ assert result == '1'
25
+ }
You can’t perform that action at this time.
0 commit comments