Skip to content

Compiler incorrectly detects dependency loop when using @typeInfo(@This()) in test #4476

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
SpexGuy opened this issue Feb 16, 2020 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@SpexGuy
Copy link
Contributor

SpexGuy commented Feb 16, 2020

Minimal Repro (tested with 0.5.0 compiler) :

const DrawCallback = fn (cmd: *DrawCmd) void;

const DrawCmd = struct {
    UserCallback: DrawCallback,
};

test "bork" {
    //var x: DrawCmd = undefined;
    _ = @typeInfo(@This());
}

Compiling this yields this error:

C:\bork.zig:4:19: error: dependency loop detected
 C:\bork.zig:1:22: note: referenced here
 C:\bork.zig:1:1: note: referenced here
 C:\bork.zig:9:9: note: referenced here

If I uncomment the first line in the test block, the program compiles successfully.

(edit: even more minimal test case)

@FireFox317
Copy link
Contributor

FireFox317 commented Feb 16, 2020

This passes with #4435

Edit: Nvm, it still shows the error when doing _ = @typeInfo(@This()).Struct.decls[0];

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Feb 18, 2020
@andrewrk andrewrk added this to the 0.7.0 milestone Feb 18, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Aug 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@marler8997
Copy link
Contributor

This also causes the dependency loop error:

test "" {
    @import("std").testing.refAllDecls(@This());
}

@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@marler8997
Copy link
Contributor

This one bit me again today. The original example no longer causes the issue to trigger though, here's a version that still triggers it:

const DrawCallback = fn (cmd: *DrawCmd) void;
const DrawCmd = struct {
    UserCallback: DrawCallback,
};
comptime { _ = DrawCallback; }

Vexu added a commit to Vexu/zig that referenced this issue Dec 31, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 31, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Jan 1, 2023
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 2024
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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

4 participants