Thread overview | |||||
---|---|---|---|---|---|
|
August 20, 2018 UDA on double nested struct | ||||
---|---|---|---|---|
| ||||
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; |
August 20, 2018 Re: UDA on double nested struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | 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. |
August 20, 2018 Re: UDA on double nested struct | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | 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. |
Copyright © 1999-2021 by the D Language Foundation