master
1fn foo() void {}
2fn bar() void {}
3
4pub export fn entry1() void {
5 const TestFn = fn () void;
6 const test_fns = [_]TestFn{ foo, bar };
7 for (test_fns) |testFn| {
8 testFn();
9 }
10}
11pub export fn entry2() void {
12 const TestFn = fn () void;
13 const test_fns = [_]TestFn{ foo, bar };
14 var i: usize = 0;
15 _ = test_fns[i];
16 _ = &i;
17}
18pub export fn entry3() void {
19 const TestFn = fn () void;
20 const test_fns = [_]TestFn{ foo, bar };
21 var i: usize = 0;
22 _ = &test_fns[i];
23 _ = &i;
24}
25// error
26//
27// :7:10: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
28// :7:10: note: use '*const fn () void' for a function pointer type
29// :15:18: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
30// :15:17: note: use '*const fn () void' for a function pointer type
31// :22:19: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
32// :22:18: note: use '*const fn () void' for a function pointer type