From 8fef23a5250efc38b16b720f298a61d793ace4e3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 27 Aug 2019 13:36:42 -0400 Subject: [PATCH] add regression test for bug fixed by lazy values closes #1310 --- test/stage1/behavior.zig | 1 + test/stage1/behavior/bugs/1310.zig | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/stage1/behavior/bugs/1310.zig diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig index 6ec1521048..49cd077669 100644 --- a/test/stage1/behavior.zig +++ b/test/stage1/behavior.zig @@ -15,6 +15,7 @@ comptime { _ = @import("behavior/bugs/1111.zig"); _ = @import("behavior/bugs/1120.zig"); _ = @import("behavior/bugs/1277.zig"); + _ = @import("behavior/bugs/1310.zig"); _ = @import("behavior/bugs/1322.zig"); _ = @import("behavior/bugs/1381.zig"); _ = @import("behavior/bugs/1421.zig"); diff --git a/test/stage1/behavior/bugs/1310.zig b/test/stage1/behavior/bugs/1310.zig new file mode 100644 index 0000000000..f0f696e4bc --- /dev/null +++ b/test/stage1/behavior/bugs/1310.zig @@ -0,0 +1,24 @@ +const std = @import("std"); +const expect = std.testing.expect; + +pub const VM = ?[*]const struct_InvocationTable_; +pub const struct_InvocationTable_ = extern struct { + GetVM: ?extern fn (?[*]VM) c_int, +}; + +pub const struct_VM_ = extern struct { + functions: ?[*]const struct_InvocationTable_, +}; + +//excised output from stdlib.h etc + +pub const InvocationTable_ = struct_InvocationTable_; +pub const VM_ = struct_VM_; + +extern fn agent_callback(_vm: [*]VM, options: [*]u8) i32 { + return 11; +} + +test "fixed" { + expect(agent_callback(undefined, undefined) == 11); +}