zig/test/cases/fn_in_struct_in_comptime.zig
Alexandros Naskos 131c133bb7 Fixed inlining determination test (#972)
When deciding wether we should inline a scope, look up the parents until we get to a function definition scope
2018-05-02 21:43:07 -04:00

18 lines
395 B
Zig

const assert = @import("std").debug.assert;
fn get_foo() fn(&u8)usize {
comptime {
return struct {
fn func(ptr: &u8) usize {
var u = @ptrToInt(ptr);
return u;
}
}.func;
}
}
test "define a function in an anonymous struct in comptime" {
const foo = get_foo();
assert(foo(@intToPtr(&u8, 12345)) == 12345);
}