Skip to content

hasIndirections doesn't take qualifiers into account with void #20812

Closed

Description

@jmdavis
void main()
{
    import std.traits;

    static assert(!hasIndirections!void);
    static assert(!hasIndirections!(const void));
    static assert(!hasIndirections!(inout void));
    static assert(!hasIndirections!(immutable void));
    static assert(!hasIndirections!(shared void));

    static assert( hasIndirections!(void*));
    static assert( hasIndirections!(const void*));
    static assert( hasIndirections!(inout void*));
    static assert( hasIndirections!(immutable void*));
    static assert( hasIndirections!(shared void*));

    static assert( hasIndirections!(void[]));
    static assert( hasIndirections!(const void[]));
    static assert( hasIndirections!(inout void[]));
    static assert( hasIndirections!(immutable void[]));
    static assert( hasIndirections!(shared void[]));

    static assert( hasIndirections!(void[42]));
    //static assert( hasIndirections!(const void[42]));
    //static assert( hasIndirections!(inout void[42]));
    //static assert( hasIndirections!(immutable void[42]));
    //static assert( hasIndirections!(shared void[42]));

    static assert(!hasIndirections!(void[0]));
    static assert(!hasIndirections!(const void[0]));
    static assert(!hasIndirections!(inout void[0]));
    static assert(!hasIndirections!(immutable void[0]));
    static assert(!hasIndirections!(shared void[0]));
}

The commented out tests fail. This is because hasIndirections tests is(E == void) and thus does not take qualifiers into account.

This bug report is on druntime rather than Phobos, because Phobos' hasIndirections is an alias of the one in core.internal.traits, so the fix needs to be in druntime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Druntime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions