Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrays init: error: dependency loop detected #16407

Closed
jiangbo opened this issue Jul 14, 2023 · 1 comment
Closed

Arrays init: error: dependency loop detected #16407

jiangbo opened this issue Jul 14, 2023 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@jiangbo
Copy link

jiangbo commented Jul 14, 2023

Zig Version

0.11.0-dev

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub const Object = struct {
    desc: []const u8,
    tag: []const u8,
    location: ?*Object = null,
};

pub const objs = [_]Object{
    .{ .desc = "an open field", .tag = "field" },
    .{ .desc = "a little cave", .tag = "cave" },
    .{ .desc = "a silver coin", .tag = "silver", .location = &objs[0] },
    .{ .desc = "a gold coin", .tag = "gold", .location = &objs[1] },
    .{ .desc = "a burly guard", .tag = "guard", .location = &objs[0] },
    .{ .desc = "yourself", .tag = "yourself", .location = &objs[0] },
};

pub fn main() !void {
    for (objs) |value| {
        std.debug.print("print: {s}", .{value});
    }
}

Expected Behavior

should be successful

@jiangbo jiangbo added the bug Observed behavior contradicts documented or intended behavior label Jul 14, 2023
@Vexu
Copy link
Member

Vexu commented Jul 14, 2023

Duplicate of #131

@Vexu Vexu marked this as a duplicate of #131 Jul 14, 2023
@Vexu Vexu closed this as completed Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants