bloomberg / clang-p2996

Experimental clang support for WG21 P2996 (Reflection).
https://github.com/bloomberg/clang-p2996/tree/p2996/P2996.md
51 stars 8 forks source link

unexpected name_of on alias member #42

Closed Pespon closed 3 months ago

Pespon commented 3 months ago

Bug Report name_of return the type name instead of the alias name when used whith alias member infos obtained via members_of. Also, calling type_of on those alias member do not compile.

To Reproduce

struct bar
{
    using int_type = int;
};

int
main(void)
{
    std::cout << name_of(members_of(^bar)[0]) << std::endl;
    // Do not compile
    // std::cout << name_of(type_of(members_of(^bar)[0])) << std::endl;
    return 0;
}

Expected behavior

int_type
int

got:

int

Additional context tested on commit c2764acc619ae358a42aa8d8fddd4bef7788aad6

katzdm commented 3 months ago

Also, calling type_of on those alias member do not compile.

I think this is correct behavior. As per D2996R3:

If r is already a type, type_of(r) is not a constant expression.

I agree that name_of(members_of(^bar)[0]) should be int_type, though - good catch!