Skip to content

Comments

Remove visiblity and lookup deprecation#7241

Closed
MartinNowak wants to merge 5 commits intodlang:masterfrom
MartinNowak:rm_import_transition
Closed

Remove visiblity and lookup deprecation#7241
MartinNowak wants to merge 5 commits intodlang:masterfrom
MartinNowak:rm_import_transition

Conversation

@MartinNowak
Copy link
Member

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @MartinNowak!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@dlang-bot dlang-bot added the Review:WIP Work In Progress - not ready for review or pulling label Oct 24, 2017
@mathias-lang-sociomantic
Copy link
Contributor

If memory serves me well, that should also automatically fix some of the issues we've seen in the past, e.g. public alias to private functions ? If so I have a test case for you. Unless you want to leave this for a later P.R. (but I fear it might get forgotten) ?

@MartinNowak
Copy link
Member Author

If memory serves me well, that should also automatically fix some of the issues we've seen in the past, e.g. public alias to private functions ? If so I have a test case for you. Unless you want to leave this for a later P.R. (but I fear it might get forgotten) ?

That at least needs to wait until we also remove the access check which is run after symbol resolution.

@RazvanN7
Copy link
Contributor

You might want to check this out [1]

[1] https://issues.dlang.org/show_bug.cgi?id=17824

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@ibuclaw ibuclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me

@andralex
Copy link
Member

andralex commented Nov 7, 2017

@MartinNowak status?

return cast(void*)s;
}

Dsymbol scopesym = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case for this added code?

return null; // don't do it for speculative compiles; too time consuming
// search for exact name ignoring visibility first
if (auto s = search(Loc(), ident, IgnoreErrors | IgnoreSymbolVisibility))
return s;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test case for added code?

@ibuclaw
Copy link
Member

ibuclaw commented Jan 5, 2018

This needs moving forward. @wilzbach I'd put this as something for the next release schedule.

@ibuclaw ibuclaw self-assigned this Jan 5, 2018
@ibuclaw
Copy link
Member

ibuclaw commented Jan 5, 2018

@MartinNowak - please rebase and add coverage tests.

@wilzbach
Copy link
Contributor

wilzbach commented Jan 8, 2018

(rebased)

@wilzbach wilzbach force-pushed the rm_import_transition branch from 3afe88b to a99e767 Compare January 23, 2018 00:10

s = searchSym();
int flags = sc.flags & SCOPE.ignoresymbolvisibility ? IgnoreSymbolVisibility : 0;
s = sym.search(e.loc, ident, flags | SearchLocalsOnly | IgnorePrivateImports);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about this line as it was very recently changed (IgnorePrivateImports was added in #7668)

@andralex
Copy link
Member

@MartinNowak status of this?

@wilzbach wilzbach force-pushed the rm_import_transition branch from a99e767 to 9aedb20 Compare January 25, 2018 00:24
@wilzbach
Copy link
Contributor

wilzbach commented Jan 25, 2018

@MartinNowak status of this?

This is still needed:

  1. The following packages remain in the "needs to be updated list"
  1. PR needs to be adapted a bit after @RazvanN7's import PRs

@andralex
Copy link
Member

andralex commented Feb 1, 2018

@jacob-carlborg @JinShil:

Is this already implemented? If not, shouldn't that be implemented first before merging this?

FYI: There's some history about that in #6078 and #5289 I'm getting confused about what the general philosophy is with regard to reflection and protection.

Sorry for the late answer. The overall philosophy (obviously not quite cast in stone yet) is that introspection should be able to bypass protection for object layout. Possibly essential tasks such as construction and destruction.

On the other hand, private module-level functions are entirely the business of the respective module and it would be unreasonable to export them just to make them accessible for introspection from another module. Same goes about private member functions.

All in all, a topic worth a closer look.

@jacob-carlborg
Copy link
Contributor

@andralex Where are we with __traits(allMembers), is that still a problem with private functions or are those not part of the result anymore?

@andralex
Copy link
Member

andralex commented Feb 1, 2018

@jacob-carlborg I think @MartinNowak worked on this recently.

@MartinNowak
Copy link
Member Author

@andralex Where are we with __traits(allMembers), is that still a problem with private functions or are those not part of the result anymore?

At the same place as before, allMembers and getMember can see private symbols, and we exempted getMember from the soon to be removed access checks. In any case that's not part of this PR.

@MartinNowak
Copy link
Member Author

On the other hand, private module-level functions are entirely the business of the respective module and it would be unreasonable to export them just to make them accessible for introspection from another module. Same goes about private member functions.

Not sure about your terminology, to clarify this.
We figured that allowing to access private symbols (of other modules, but in the same DSO) has negligible performance implications for compilers, so we disabled visibility checks for those traits (

// ignore symbol visibility for these traits, should disable access checks as well
).
There are still the old access checks that have been here since ever. Those will be removed once the deprecation phase for visibility ended (this PR).

It's weird that a thread with a consensus (https://forum.dlang.org/post/nq512d$9po$1@digitalmars.com) still leaves so much confusion and uncertainty.

@MartinNowak
Copy link
Member Author

FYI: There's some history about that in #6078 and #5289 I'm getting confused about what the general philosophy is with regard to reflection and protection.

There is an old mechanism (access checks) and a new one (visibility checks). Once visibility is fully deprecated (with this PR), we'll remove the access checks.
Indeed after some discussion we decided to ignore visibility for allMembers and getMember. The old access check has (and still does) error on access private fields via getMember though. As a limited workaround, one can use .tupleof. Reflection on private fields should fully work as reflection does not access a symbol (it only looks at it).

@wilzbach wilzbach removed this from the 2.079.0 milestone Apr 6, 2018
@wilzbach
Copy link
Contributor

wilzbach commented Jul 29, 2018

 CyberShadow/ae#33 (there's a weird error with the deprecation only showing up with -de)

FYI: this has been reduced by Mike to https://issues.dlang.org/show_bug.cgi?id=19107 and been proposed as #8519

@wilzbach
Copy link
Contributor

Superseded by #9636

@wilzbach wilzbach closed this Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.