diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig index 2d53122706..3ffa0a3a12 100644 --- a/test/behavior/eval.zig +++ b/test/behavior/eval.zig @@ -572,28 +572,6 @@ test "inlined loop has array literal with elided runtime scope on first iteratio } } -test "call method on bound fn referring to var instance" { - if (builtin.zig_backend != .stage1) { - // Let's delay solving this one; I want to try to eliminate bound functions from - // the language. - return error.SkipZigTest; // TODO - } - - try expect(bound_fn() == 1237); -} - -const SimpleStruct = struct { - field: i32, - - fn method(self: *const SimpleStruct) i32 { - return self.field + 3; - } -}; - -var simple_struct = SimpleStruct{ .field = 1234 }; - -const bound_fn = simple_struct.method; - test "ptr to local array argument at comptime" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO diff --git a/test/cases/compile_errors/call method on bound fn referring to var instance.zig b/test/cases/compile_errors/call method on bound fn referring to var instance.zig new file mode 100644 index 0000000000..10ff584124 --- /dev/null +++ b/test/cases/compile_errors/call method on bound fn referring to var instance.zig @@ -0,0 +1,20 @@ +export fn entry() void { + bad(bound_fn() == 1237); +} +const SimpleStruct = struct { + field: i32, + + fn method(self: *const SimpleStruct) i32 { + return self.field + 3; + } +}; +var simple_struct = SimpleStruct{ .field = 1234 }; +const bound_fn = simple_struct.method; +fn bad(ok: bool) void { + _ = ok; +} +// error +// target=native +// backend=stage2 +// +// :12:18: error: unable to resolve comptime value