move bound function behavior test to compile error test

This commit is contained in:
Andrew Kelley
2022-05-23 19:49:04 -07:00
parent 1bf7a6dff5
commit 7db39384f7
2 changed files with 20 additions and 22 deletions

View File

@@ -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

View File

@@ -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