@@ -558,3 +558,19 @@ test "call generic function with from function called by the generic function" {
ArgSerializer.serializeCommand(GET{ .key = "banana" });
}
fn StructCapture(comptime T: type) type {
return struct {
pub fn foo(comptime x: usize) struct { T } {
return .{x};
}
};
}
test "call generic function that uses capture from function declaration's scope" {
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
const S = StructCapture(f64);
const s = S.foo(123);
try expectEqual(123.0, s[0]);
}