Skip to content

ability for global variables to be initialized with address of each other #131

Description

@andrewrk
const std = @import("std");
const expect = std.testing.expect;

const Node = struct {
    next: *Node,
};

const a: Node = .{ .next = &b };
const b: Node = .{ .next = &a };

test "example" {
    expect(a.next == &b);
    expect(b.next == &a);
}

Currently, this test case produces the following results:

test.zig:8:1: error: dependency loop detected
const a: Node = .{ .next = &b };
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    a: test.zig:8:29
    b: test.zig:9:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions