Commit 2ad6ca581d

Stevie Hryciw <codroid@gmail.com>
2023-08-07 03:23:28
Add behavior test for copying self-referential struct
Closes #6312. In the C++ implementation this caused a stack overflow from infinite recursion during analysis.
1 parent 16dcefa
Changed files (1)
test
behavior
test/behavior/bugs/6305.zig
@@ -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;
+}