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

Separate compilation changes result of __traits(compiles) #19511

Open
dlangBugzillaToGithub opened this issue Nov 20, 2018 · 0 comments
Open
Labels

Comments

@dlangBugzillaToGithub
Copy link

Paul Backus (@pbackus) reported this on 2018-11-20T20:11:02Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19417

Description

The following program prints "true" when compiled together, and "false" when compiled separately:

--- dub.json
{
    "name": "example"
}

--- source/app.d
import node;

void main()
{
    import std.stdio;
    writeln(__traits(compiles, Struct.init == Struct.init));
}

--- source/node.d
import example;

alias Node = Example!Struct;
struct Struct { Node[] nodes; }

--- source/example.d
struct Example(T)
{
    T t;

    static if (__traits(compiles, T.init == T.init)) {
        bool opEquals(Example!T rhs) { return this.t == rhs.t; }
    } else {
        @disable bool opEquals(Example!T rhs);
    }
}

---

To build and run with dub:

$ dub --quiet build --build-mode=singleFile --force && dub --quiet run                                                                                   
false
$ dub --quiet build --force && dub --quiet run                                                                                                           
true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant