Privacy violation depending on who passes a compile-time argument?
rcorre via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 14 05:03:28 PDT 2016
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?
More information about the Digitalmars-d-learn
mailing list