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

unit_threaded.assertions.convertToString logic is a bit messed up #289

Open
John-Colvin opened this issue Mar 23, 2023 · 3 comments
Open

Comments

@John-Colvin
Copy link
Contributor

John-Colvin commented Mar 23, 2023

it's trying __traits(compiles on text_, which isn't a template in it's own right, so if you've got to the check then it must pass. Also text_ can end up not returning. I guess making it a no-arg template would fix the problem? Idk.

@atilaneves
Copy link
Owner

text_ isn't a template, but it calls text, and that is. What is the actual issue?

@John-Colvin
Copy link
Contributor Author

If text_ doesn't compile, then the whole convertToString template cannot be instantiated.

The pattern is essentially this:

template A(T) {
    void foo() { potentiallyBad!T(); }
    static if (__traits(compiles, foo())) {
        enum A = 0;
    } else {
        enum A = 1;
    }
}

There is no way that A!(X) can ever be 1, regardless of X and regardless of the implementation of potentiallyBad. Either A!(X) is 0 or it fails to compile.

Now in your case there is one small difference: convertToString takes its argument as const, which means you are indeed checking whether T : const(T). But is that what was actually intended?

@atilaneves
Copy link
Owner

I don't remember, but I doubt I wrote that without needing to since... that's not me. I still don't know what the actual issue is.

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

2 participants