Add behavior test for copying self-referential struct

Closes #6312. In the C++ implementation this caused a stack overflow
from infinite recursion during analysis.
This commit is contained in:
Stevie Hryciw
2023-08-06 18:23:28 -07:00
parent 16dcefaca5
commit 2ad6ca581d

View File

@@ -0,0 +1,10 @@
const ListNode = struct {
next: ?*const @This() = null,
};
test "copy array of self-referential struct" {
comptime var nodes = [_]ListNode{ .{}, .{} };
nodes[0].next = &nodes[1];
const copy = nodes;
_ = copy;
}