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

Unknown error while instantiating: __traits(compiles) hides the real issue #5576

Open
dlangBugzillaToGithub opened this issue Nov 13, 2024 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link
Owner

ilya.yanok reported this on 2024-11-13T12:03:09Z

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

CC List

  • Luís Ferreira
  • Nick Treleaven

Description

dustmite minimized example (probably could be minimized a bit further):
```
template AllMembersInModule(alias Module) {
    import std: AliasSeq, Filter;
    alias all_members = AliasSeq!(__traits(allMembers, Module));

    template CanAccess(string member) {
        enum CanAccess = __traits(compiles, __traits(getMember, Module, member));
    }
    alias x = Filter!(CanAccess, all_members);

    alias AllMembersInModule = y;
}

template t() {
    alias MODULE = __traits(parent, {});
    static foreach (M; AllMembersInModule!MODULE) {
        }
}

alias AllMembers = AllMembersInModule!(__traits(parent, {}));
mixin t;
```

The issue here is a typo: `y` should be `x`, but we get an unknown error instead.

If I remove `alias AllMembers` it works as expected.

BTW, if I remove `mixin t` line, it compiles without error, is it expected, are aliases lazy?
@dlangBugzillaToGithub
Copy link
Owner Author

nick commented on 2024-11-13T16:34:33Z

I couldn't reduce it any more than this:

```
template AllMembersInModule(alias Module) {
    import std.meta : Filter;
    alias all_members = __traits(allMembers, Module);

    template CanAccess(string member) {
        enum CanAccess = __traits(compiles, __traits(getMember, Module, member));
    }
    alias x = Filter!(CanAccess, all_members);

    alias AllMembersInModule = y;
}

alias AllMembers = AllMembersInModule!(__traits(parent, {}));
pragma(msg, AllMembers); // added
```

Error: unknown, please file report on issues.dlang.org
aliastypo.d(15):        while evaluating `pragma(msg, AllMembers)`

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

No branches or pull requests

1 participant