Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for is(T : ...) tests testing for noreturn #863

Open
WebFreak001 opened this issue Apr 21, 2022 · 0 comments
Open

Add check for is(T : ...) tests testing for noreturn #863

WebFreak001 opened this issue Apr 21, 2022 · 0 comments

Comments

@WebFreak001
Copy link
Member

See https://forum.dlang.org/thread/xmjabqpofltdwxfqlwhi@forum.dlang.org

code like

struct Something(Types...) {}

enum isSomething(T) = is(T : Something!Types, Types...);

might be how users write custom is-checks to see if a given type is some templated type, however for isSomething!noreturn this returns true, which might be unexpected for the user. (see forum discussion)

My check idea to add would be warning if noreturn isn't explicitly handled for global templates or maybe even everywhere. (could be configurable)

so for the code above it would give a warning and the user would have a few choices to fix it:

// noreturn is not Something
enum isSomething(T) = is(T : Something!Types, Types...)
    && !is(immutable T == immutable noreturn);

// noreturn is Something
enum isSomething(T) = is(T : Something!Types, Types...)
    || is(immutable T == immutable noreturn);

// only match exact Something (no alias this support anymore though)
enum isSomething(T) = is(T == Something!Types, Types...);

to keep the check simple it would just check for any is(T : ...) expression and see if in the same expression or template T is compared with noreturn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant