Skip to content

Setting member default values causes false detection of a dependency loop #17533

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

Closed
papparapa opened this issue Oct 15, 2023 · 3 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@papparapa
Copy link

Zig Version

0.12.0-dev.926+3be8490d8

Steps to Reproduce and Observed Behavior

The following codes cannot be compiled.

const A = struct {
    b: ?*B = null,
    n: usize,
};

const B = struct {
    a: A = A{ .n = 1 },
};

pub fn main() void {
    _ = A{ .n = 10 };
}
$ zig build-exe false_dependency_loop.zig
false_dependency_loop.zig:1:11: error: struct 'false_dependency_loop.A' depends on itself
const A = struct {
          ^~~~~~
$

Expected Behavior

I expect the compile gets successful since A.b is a pointer.

@papparapa papparapa added the bug Observed behavior contradicts documented or intended behavior label Oct 15, 2023
@kcbanner
Copy link
Contributor

#17490 may solve this

@kcbanner
Copy link
Contributor

Confirming that PR does fix this case.

@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Oct 15, 2023
@Vexu Vexu added this to the 0.12.0 milestone Oct 15, 2023
@papparapa
Copy link
Author

I found that this issue was resolved in 0.12.0-dev.1504+81219586b at the latest, meybe thanks to #17692

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 frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
3 participants