Skip to content

No completion with usingnamespace struct functions  #1231

@Beyley

Description

@Beyley

Zig Version

0.11.0-dev.3382+c16d4ab9e

Zig Language Server Version

1020817

Steps to Reproduce

Create a struct, have that struct inhert some functions using usingnamespace, you dont get completion on the type, some code i have which exhibits the behaviour is

fn ChannelFunctions(comptime Type: type) type {
    return struct {
        pub fn play(self: Type, restart: bool) !void {
            const success = c.BASS_ChannelPlay(self.handle, if (restart) 1 else 0);
            if (success != 0) return;
            return bassErrorToZigError(c.BASS_ErrorGetCode());
        }

        pub fn setAttribute(self: Type, attribute: ChannelAttribute, value: f32) !void {
            const success = c.BASS_ChannelSetAttribute(self.handle, @enumToInt(attribute), value);

            if (success == 0) {
                return bassErrorToZigError(c.BASS_ErrorGetCode());
            }
        }

        pub fn channelGetSecondPosition(self: Type) !f64 {
            var byte_pos = c.BASS_ChannelGetPosition(self.handle, c.BASS_POS_BYTE);

            if (byte_pos == @bitCast(u64, @as(i64, -1))) {
                return bassErrorToZigError(c.BASS_ErrorGetCode());
            }

            var second_pos = c.BASS_ChannelBytes2Seconds(self.handle, byte_pos);

            if (second_pos < 0) {
                return bassErrorToZigError(c.BASS_ErrorGetCode());
            }

            return second_pos;
        }
    };
}

pub const Stream = extern struct {
    pub usingnamespace ChannelFunctions(Stream);

    handle: u32,

    pub fn deinit(self: Stream) void {
        var success = c.BASS_StreamFree(self.handle);

        if (success == 0) {
            std.debug.panicExtra(null, null, "Unknown error during BASS_Free??? err:{d}\n", .{c.BASS_ErrorGetCode()});
        }
    }
};

Expected Behavior

When i try to get completions on the struct, all fields/structs inherited by usingnamespace appear as completions

Actual Behavior

when i try to get completions on the struct, the ones inherited by usingnamespace are missing
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions