www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - UDA on double nested struct

reply Sebastiaan Koppe <mail skoppe.eu> writes:
Hey, I am trying to get UDAs from a doubly nested struct, to no 
avail:

code
---
import std.traits : hasUDA;
enum hover;

struct Style {
   struct Root {
     auto margin = "10px";
     auto backgroundColor = "white";
      hover struct Hover {
       auto backgroundColor = "gray";
     }
   }
}
pragma(msg, hasUDA!(Style.Root.Hover, hover));
---

returns false. Bug or no? (Yes, I am generating css at compile 
time.)

Putting it on Root or on Style works as intended;
Aug 20 2018
parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 20 August 2018 at 16:16:04 UTC, Sebastiaan Koppe wrote:
 Hey, I am trying to get UDAs from a doubly nested struct, to no 
 avail:

 code
 ---
 import std.traits : hasUDA;
 enum hover;

 struct Style {
   struct Root {
     auto margin = "10px";
     auto backgroundColor = "white";
      hover struct Hover {
       auto backgroundColor = "gray";
     }
   }
 }
 pragma(msg, hasUDA!(Style.Root.Hover, hover));
 ---

 returns false. Bug or no? (Yes, I am generating css at compile 
 time.)

 Putting it on Root or on Style works as intended;
Hello, it works fine here. Maybe there was another error that you removed when you have minimized the example. See https://run.dlang.io/is/ZrW7kI, that says that the example works since 2.068.2. Although that are are possibility that it was broken before a patch release, since only latest path of a minor release is tested on the site, in which case updating the compiler would fix the issue.
Aug 20 2018
parent Sebastiaan Koppe <mail skoppe.eu> writes:
On Monday, 20 August 2018 at 16:27:55 UTC, Basile B. wrote:
 Hello, it works fine here. Maybe there was another error that 
 you removed when you have minimized the example. See 
 https://run.dlang.io/is/ZrW7kI, that says that the example 
 works since 2.068.2. Although that are are possibility that it 
 was broken before a patch release, since only latest path of a 
 minor release is tested on the site, in which case updating the 
 compiler would fix the issue.
Wow, that is really nice, running all compilers at once. Thanks for showing that. Anyway, I found out that the problem was that the `Hover` struct was named `hover` in my code. See https://run.dlang.io/is/3dLli6 In that case the inner hover takes precedence over the enum hover. Is that wanted behaviour? I would at minimum expect an ambiguity error.
Aug 20 2018