Skip to content

Fields of type type are apparently actually &const type #958

Closed
@Hejsil

Description

@Hejsil
const S = struct {
    T: type
};

// error: expected type 'type', found '&const type'
//                         V
fn takeS(comptime s: S, a: &s.T) void { }

test "" {
    var a : u8 = 0;
    const s = S { .T = u8 };
    takeS(s, &a);
}

Deref the &const type, and we get this error:

const S = struct {
    T: type
};

fn takeS(comptime s: S, a: &*s.T) void { }

test "" {
    var a : u8 = 0;
    const s = S { .T = u8 };
    takeS(s, &a); // error: expected type 'u8', found '&u8'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions