behavior tests: stage2 is not yet passing this test

Looks like I repeated the same mistake, which last time was addressed in
1e0addcf73.
This commit is contained in:
Andrew Kelley
2021-12-22 20:48:53 -07:00
parent cc937369fb
commit 303bad9989
2 changed files with 35 additions and 35 deletions

View File

@@ -91,38 +91,3 @@ const Expr = union(enum) {
fn alloc(comptime T: type) []T {
return &[_]T{};
}
test "for loop over pointers to struct, getting field from struct pointer" {
const S = struct {
const Foo = struct {
name: []const u8,
};
var ok = true;
fn eql(a: []const u8) bool {
_ = a;
return true;
}
const ArrayList = struct {
fn toSlice(self: *ArrayList) []*Foo {
_ = self;
return @as([*]*Foo, undefined)[0..0];
}
};
fn doTheTest() !void {
var objects: ArrayList = undefined;
for (objects.toSlice()) |obj| {
if (eql(obj.name)) {
ok = false;
}
}
try expect(ok);
}
};
try S.doTheTest();
}

View File

@@ -649,3 +649,38 @@ test "packed struct with undefined initializers" {
try S.doTheTest();
comptime try S.doTheTest();
}
test "for loop over pointers to struct, getting field from struct pointer" {
const S = struct {
const Foo = struct {
name: []const u8,
};
var ok = true;
fn eql(a: []const u8) bool {
_ = a;
return true;
}
const ArrayList = struct {
fn toSlice(self: *ArrayList) []*Foo {
_ = self;
return @as([*]*Foo, undefined)[0..0];
}
};
fn doTheTest() !void {
var objects: ArrayList = undefined;
for (objects.toSlice()) |obj| {
if (eql(obj.name)) {
ok = false;
}
}
try expect(ok);
}
};
try S.doTheTest();
}