v4 / vlib / v / checker / tests / comptime_call_method_mut_pointer_err.vv
26 lines · 21 sloc · 335 bytes · 5f4d1047ead7989df521daca23a6907cf8135a5c
Raw
1module main
2
3struct Context {
4mut:
5 value int
6}
7
8struct App {}
9
10fn (_ App) index(mut ctx &Context) {
11 ctx.value++
12}
13
14fn call(app App, mut user_context Context) {
15 $for method in App.methods {
16 if method.name == 'index' {
17 app.$method(mut user_context)
18 }
19 }
20}
21
22fn main() {
23 app := App{}
24 mut ctx := Context{}
25 call(app, mut ctx)
26}
27