Bug 24857 – Unknown error while instantiating: __traits(compiles) hides the real issue

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-11-13T12:03:09Z
Last change time
2024-12-13T19:38:30Z
Keywords
accepts-invalid, ice-on-invalid-code, industry
Assigned to
No Owner
Creator
ilya.yanok
Moved to GitHub: dmd#20545 →

Comments

Comment #0 by ilya.yanok — 2024-11-13T12:03:09Z
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?
Comment #1 by nick — 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)`
Comment #2 by robert.schadek — 2024-12-13T19:38:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20545 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB