Skip to content

@fieldParentPtr can cause unnecessary "struct depends on itself" error #7679

@daurnimator

Description

@daurnimator
./uring-nonblock-fifo-async.zig:143:16: error: struct 'Client' depends on itself
const Client = struct {
               ^
./uring-nonblock-fifo-async.zig:347:22: note: referenced here
            sqe.fd = @fieldParentPtr(Client, "writer", self).fd;
                     ^
./uring-nonblock-fifo-async.zig:329:35: note: while checking if 'Writer.write' is async
                    try self.flush(ring);
                                  ^
./uring-nonblock-fifo-async.zig:248:41: note: when analyzing type '@Frame(Reader.run)' here
                        try Writer.write(client, ring, HTTP_RESPONSE);
                                        ^
./uring-nonblock-fifo-async.zig:195:19: note: while checking if 'Client.run' is async
        Reader.run(self, ring) catch |err| switch (err) {
                  ^
./uring-nonblock-fifo-async.zig:151:5: note: while checking this field
    frame: @Frame(run),
    ^
./uring-nonblock-fifo-async.zig:172:19: note: referenced here
        self.* = .{
                  ^
./uring-nonblock-fifo-async.zig:118:57: note: referenced here
            const client = Client.init(self, client_fd) catch |err| {
                                                        ^
./uring-nonblock-fifo-async.zig:15:17: note: referenced here
        try ring.poll();
                ^
./uring-nonblock-fifo-async.zig:67:26: note: referenced here
        while (self.queue.popFirst()) |node| {
                         ^
./uring-nonblock-fifo-async.zig:72:27: note: referenced here
        _ = try self.inner.submit_and_wait(1);
                          ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:166:29: note: referenced here
        var submitted = self.flush_sq();
                            ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:168:17: note: referenced here
        if (self.sq_ring_needs_enter(submitted, &flags) or wait_nr > 0) {
                ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:169:51: note: referenced here
            if (wait_nr > 0 or (self.flags & linux.IORING_SETUP_IOPOLL) != 0) {
                                                  ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:170:31: note: referenced here
                flags |= linux.IORING_ENTER_GETEVENTS;
                              ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:172:28: note: referenced here
            return try self.enter(submitted, wait_nr, flags);
                           ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:181:26: note: referenced here
        const res = linux.io_uring_enter(self.fd, to_submit, min_complete, flags, null);
                         ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:191:18: note: referenced here
            linux.EBADFD => return error.FileDescriptorInBadState,
                 ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:194:18: note: referenced here
            linux.EBUSY => return error.CompletionQueueOvercommitted,
                 ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:201:18: note: referenced here
            linux.ENXIO => return error.RingShuttingDown,
                 ^
/home/daurnimator/src/zig/lib/std/os/linux/io_uring.zig:204:18: note: referenced here
            linux.EOPNOTSUPP => return error.OpcodeNotSupported,
                 ^
./uring-nonblock-fifo-async.zig:73:13: note: referenced here
        self.flushCompletions();
            ^
/home/daurnimator/src/zig/lib/std/start.zig:346:20: note: referenced here
                std.log.err("{s}", .{@errorName(err)});
                   ^
/home/daurnimator/src/zig/lib/std/log.zig:237:21: note: referenced here
pub const default = scoped(.default);
                    ^
/home/daurnimator/src/zig/lib/std/log.zig:257:17: note: referenced here
pub const err = default.err;
                ^
/home/daurnimator/src/zig/lib/std/log.zig:257:24: note: referenced here
pub const err = default.err;
                       ^
/home/daurnimator/src/zig/lib/std/start.zig:346:24: note: referenced here
                std.log.err("{s}", .{@errorName(err)});
                       ^

Found while working on https://gist.github.com/daurnimator/699320cda828303671a21d15bb4a3753#file-uring-nonblock-fifo-async-zig

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions