digitalmars.D - Possible regression (2.060 -> 2.061) with member access
- Benjamin Thaut <code benjamin-thaut.de> Feb 09 2013
- kenji hara <k.hara.pg gmail.com> Feb 09 2013
- Benjamin Thaut <code benjamin-thaut.de> Feb 09 2013
- Jacob Carlborg <doob me.com> Feb 09 2013
- "Dicebot" <m.strashun gmail.com> Feb 09 2013
- Andrej Mitrovic <andrej.mitrovich gmail.com> Feb 09 2013
- Jacob Carlborg <doob me.com> Feb 09 2013
- Benjamin Thaut <code benjamin-thaut.de> Feb 10 2013
- Benjamin Thaut <code benjamin-thaut.de> Feb 10 2013
- Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> Feb 09 2013
- Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> Feb 09 2013
- "Dicebot" <m.strashun gmail.com> Feb 10 2013
- "Dicebot" <m.strashun gmail.com> Feb 10 2013
The following reduced source code would compile just fine with dmd 2.060
but does no longer compile with dmd 2.061:
file a.d:
module a;
import b;
template getType(T)
{
alias typeof(T.i) getType;
}
void main(string[] args)
{
alias getType!Foo t;
}
file b.d:
module b;
struct Foo
{
private int i;
}
This breaks all kind of low level functionality I did build. It breaks
both my serialization code and runtime type information system. Because
in both use cases I need to be able to access the type of a protected or
private member.
Has this been "fixed" intentionally? Or is this a regression? If it has
been "fixed" what would be a workaround to get the type of Foo.i
(outside of the b module) ?
Kind Regards
Benjamin Thaut
Feb 09 2013
--f46d044306b033ab6a04d54c8096 Content-Type: text/plain; charset=UTF-8 2013/2/10 Benjamin Thaut <code benjamin-thaut.de>The following reduced source code would compile just fine with dmd 2.060 but does no longer compile with dmd 2.061: file a.d: module a; import b; template getType(T) { alias typeof(T.i) getType; } void main(string[] args) { alias getType!Foo t; } file b.d: module b; struct Foo { private int i; } This breaks all kind of low level functionality I did build. It breaks both my serialization code and runtime type information system. Because in both use cases I need to be able to access the type of a protected or private member. Has this been "fixed" intentionally? Or is this a regression?
It's introduced by fixing issue 5385, so at least not a regressionIf it has been "fixed" what would be a workaround to get the type of Foo.i (outside of the b module)
You can use built-in 'tupleof' property, which still bypass access modifier. Kenji Hara --f46d044306b033ab6a04d54c8096 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">2013/2/10 Benjamin Thaut <span dir=3D"ltr"><<a href=3D"= mailto:code benjamin-thaut.de" target=3D"_blank">code benjamin-thaut.de</a>= ></span><br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><block= quote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-w= idth:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding= -left:1ex"> The following reduced source code would compile just fine with dmd 2.060 bu= t does no longer compile with dmd 2.061:<br> <br> file a.d:<br> module a;<br> <br> import b;<br> <br> template getType(T)<br> {<br> =C2=A0 alias typeof(T.i) getType;<br> }<br> <br> void main(string[] args)<br> {<br> =C2=A0 alias getType!Foo t;<br> }<br> <br> <br> file b.d:<br> module b;<br> <br> struct Foo<br> {<br> =C2=A0 private int i;<br> }<br> <br> <br> This breaks all kind of low level functionality I did build. It breaks both= my serialization code and runtime type information system. Because in both= use cases I need to be able to access the type of a protected or private m= ember.<br> <br> Has this been "fixed" intentionally? Or is this a regression?</bl= ockquote><div><br></div><div style>It's introduced by fixing=C2=A0issue= 5385, so at least=C2=A0not a regression</div><div>=C2=A0<br></div><blockqu= ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-wid= th:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-l= eft:1ex"> If it has been "fixed" what would be a workaround to get the type= of Foo.i (outside of the b module)=C2=A0<br></blockquote><div><br></div><d= iv style>You can use built-in 'tupleof' property, which still bypas= s access modifier.=C2=A0<br> </div><div style><br></div><div style>Kenji Hara</div></div></div></div> --f46d044306b033ab6a04d54c8096--
Feb 09 2013
Am 09.02.2013 16:40, schrieb kenji hara:You can use built-in 'tupleof' property, which still bypass access modifier.
Will they continue to do so, or will this also be fixed? We should at least have some way to do low level work like serialization. Kind Regards Benjamin Thaut
Feb 09 2013
On 2013-02-09 16:20, Benjamin Thaut wrote:Has this been "fixed" intentionally? Or is this a regression? If it has been "fixed" what would be a workaround to get the type of Foo.i (outside of the b module) ?
The workaround would be to use .tupleof: https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L237 -- /Jacob Carlborg
Feb 09 2013
On Saturday, 9 February 2013 at 15:52:04 UTC, Benjamin Thaut wrote:Am 09.02.2013 16:40, schrieb kenji hara:You can use built-in 'tupleof' property, which still bypass access modifier.
Will they continue to do so, or will this also be fixed? We should at least have some way to do low level work like serialization. Kind Regards Benjamin Thaut
According to my private-related DIP - yes, they will continue, and there have been no objections on this part.
Feb 09 2013
On 2/9/13, kenji hara <k.hara.pg gmail.com> wrote:It's introduced by fixing issue 5385, so at least not a regression
Perhaps we could relax the rule and allow bypassing access restrictions when using typeof(). There are similar bugs opened about purity, where e.g. you can't check the length of an impure static array in a pure function (even though it will never change length). I think we'll have to define in the spec exactly what is and isn't allowed and then implement this properly, otherwise we risk fixing bug for person #1 which ends up breaking code for person #2 (which is exactly what happened with fixing 5385).
Feb 09 2013
On 2013-02-09 21:51, Nick Sabalausky wrote:I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.
Couldn't typeof() be considered part of a reflection mechanism? -- /Jacob Carlborg
Feb 09 2013
Am 10.02.2013 11:21, schrieb Dicebot:On Saturday, 9 February 2013 at 22:54:09 UTC, Jacob Carlborg wrote:On 2013-02-09 21:51, Nick Sabalausky wrote:I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.
Couldn't typeof() be considered part of a reflection mechanism?
May be, but definitely not an advanced librar'ish one - contrary to .tupleof and some __traits is is a pretty common guest in user code.
Really? I'm using typeof all over the place in my user code.
Feb 10 2013
Am 10.02.2013 11:55, schrieb Dicebot:On Sunday, 10 February 2013 at 10:22:59 UTC, Benjamin Thaut wrote:Really? I'm using typeof all over the place in my user code.
That is exactly what I have just said :) And reason why it should behave according to usual protection attribute rules.
Oh ok, then I misunderstood your argument.
Feb 10 2013
On Sat, 9 Feb 2013 21:34:54 +0100 Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:On 2/9/13, kenji hara <k.hara.pg gmail.com> wrote:It's introduced by fixing issue 5385, so at least not a regression
Perhaps we could relax the rule and allow bypassing access restrictions when using typeof().
I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.
Feb 09 2013
On Sat, 09 Feb 2013 23:54:09 +0100 Jacob Carlborg <doob me.com> wrote:On 2013-02-09 21:51, Nick Sabalausky wrote:I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.
Couldn't typeof() be considered part of a reflection mechanism?
Yea, but not the part of reflection I was trying to refer to. Wasn't sure what to call it besides the overly-general "reflection mechanism".
Feb 09 2013
On Saturday, 9 February 2013 at 22:54:09 UTC, Jacob Carlborg wrote:On 2013-02-09 21:51, Nick Sabalausky wrote:I think that's asking for confusion to have different visibility rules inside and outside typeof(). The typical way to access private members when really needed is via a reflection mechanism, and we already have a way to do that as two people have mentioned.
Couldn't typeof() be considered part of a reflection mechanism?
May be, but definitely not an advanced librar'ish one - contrary to .tupleof and some __traits is is a pretty common guest in user code.
Feb 10 2013
On Sunday, 10 February 2013 at 10:22:59 UTC, Benjamin Thaut wrote:Really? I'm using typeof all over the place in my user code.
That is exactly what I have just said :) And reason why it should behave according to usual protection attribute rules.
Feb 10 2013









Benjamin Thaut <code benjamin-thaut.de> 