Thread overview | |||||
---|---|---|---|---|---|
|
May 18, 2013 [Issue 10111] New: getProtection trait should work with inaccessible fields | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10111 Summary: getProtection trait should work with inaccessible fields Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-05-17 17:30:56 PDT --- ----- module foo; struct S { private void m() { } } ----- ----- module test; import foo; void main() { static if (__traits(getProtection, S.m != "private")) { // field might be accessible } } ----- $ dmd test.d > test.d(7): Error: struct foo.S member m is not accessible There's not much point in having this trait if it fails to compile due to accessibility problems. The trait has only one purpose and it's to return a string representation of a symbol's protection. There's nothing damaging about allowing it access to all fields, so I think the above should work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 18, 2013 [Issue 10111] getProtection trait should work with inaccessible fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=10111 Igor Stepanov <wazar.leollone@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wazar.leollone@yahoo.com --- Comment #1 from Igor Stepanov <wazar.leollone@yahoo.com> 2013-05-17 17:35:58 PDT --- is this bug is regression? You was created an another issue: http://d.puremagic.com/issues/show_bug.cgi?id=9546 In #9546 same tests was passed. >static assert(__traits(getProtection, s.privA) == "private"); >static assert(__traits(getProtection, s.protA) == "protected"); >static assert(__traits(getProtection, s.packA) == "package"); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 18, 2013 [Issue 10111] getProtection trait should work with inaccessible fields | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=10111 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-05-17 17:42:10 PDT --- God what a silly typo: static if (__traits(getProtection, S.m != "private")) The parenthesis is wrong, it should be: static if (__traits(getProtection, S.m) != "private") -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation