Skip to content

Compiler should not permit fields with function types and struct functions to share the same name #1836

Closed
@tgschultz

Description

@tgschultz
pub const S = struct
{
    func: fn() usize,
    
    pub fn func(self: *S) usize
    {
        return 2;
    }
};

pub fn func() usize
{
    return 1;
}

test ""
{
    var s = S{ .func = func, };
    debug.assert(s.func() == 2); //ambiguous
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions