Can someone help me understand why the first line is fine, but the second triggers a deprecation warning for access to a private variable?

---
import std.traits;
import s;

pragma(msg, hasUDA!(S.getMember_i, attr));   // fine
pragma(msg, hasUDA!(S.getMember!"i", attr)); // deprecated

/++ in module 's'
import std.traits;

struct attr { }

struct S {
  @attr private int i;
alias getMember(string name) = Identity!(__traits(getMember, S, name));
  alias getMember_i = getMember!"i";
}
++/
---

getMember is not a mixin template, so it seems like __traits(getMember, S, "i") should be resolved within the 's' module in both cases. Why is passing the string "i" from another module a violation even when getMember_i is doing the same thing internally?

Reply via email to