Bug 16085 – wrong visibility warning for overloaded alias symbol

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-05-27T20:08:00Z
Last change time
2016-11-04T09:04:58Z
Keywords
pull
Assigned to
code
Creator
andrei

Comments

Comment #0 by andrei — 2016-05-27T20:08:39Z
Related pull coming.
Comment #1 by andrei — 2016-05-27T20:08:58Z
Comment #2 by code — 2016-05-27T20:14:38Z
Error case import common = std.experimental.allocator.common : roundUpToMultipleOf, reallocate; common.reallocate(foo, bar);
Comment #3 by code — 2016-05-29T19:38:08Z
Error message at https://github.com/dlang/phobos/commit/140c51447feb951d62016cf62d8349e013ecd521^ std/experimental/allocator/building_blocks/segregator.d(188): Deprecation: std.experimental.allocator.building_blocks.bucketizer.Bucketizer!(FreeList!(GCAllocator, 0LU, 18446744073709551615LU, cast(Flag)false), 1LU, 128LU, 16LU).Bucketizer.reallocate is not visible from module std.experimental.allocator.building_blocks.segregator std/experimental/allocator/building_blocks/segregator.d(182): Deprecation: std.experimental.allocator.building_blocks.bucketizer.Bucketizer!(FreeList!(GCAllocator, 0LU, 18446744073709551615LU, cast(Flag)false), 129LU, 256LU, 32LU).Bucketizer.reallocate is not visible from module std.experimental.allocator.building_blocks.segregator std/experimental/allocator/building_blocks/segregator.d(188): Deprecation: std.experimental.allocator.building_blocks.bucketizer.Bucketizer!(FreeList!(GCAllocator, 0LU, 18446744073709551615LU, cast(Flag)false), 257LU, 512LU, 64LU).Bucketizer.reallocate is not visible from module std.experimental.allocator.building_blocks.segregator std/experimental/allocator/building_blocks/segregator.d(182): Deprecation: std.experimental.allocator.building_blocks.bucketizer.Bucketizer!(FreeList!(GCAllocator, 0LU, 18446744073709551615LU, cast(Flag)false), 513LU, 1024LU, 128LU).Bucketizer.reallocate is not visible from module std.experimental.allocator.building_blocks.segregator std/experimental/allocator/building_blocks/segregator.d(188): Deprecation: std.experimental.allocator.building_blocks.bucketizer.Bucketizer!(FreeList!(GCAllocator, 0LU, 18446744073709551615LU, cast(Flag)false), 1025LU, 2048LU, 256LU).Bucketizer.reallocate is not visible from module std.experimental.allocator.building_blocks.segregator std/experimental/allocator/building_blocks/segregator.d(182): Deprecation: std.experimental.allocator.building_blocks.bucketizer.Bucketizer!(FreeList!(GCAllocator, 0LU, 18446744073709551615LU, cast(Flag)false), 2049LU, 3584LU, 512LU).Bucketizer.reallocate is not visible from module std.experimental.allocator.building_blocks.segregator
Comment #4 by code — 2016-05-29T19:39:09Z
This is just an occurrence of wrong code caused by issue 314, b/c selective imports weren't checked for visibility until recently. struct Bucketizer { import whatever : reallocate; // <- private } struct Segregator(LargeAllocator) { LargeAllocator _large; void reallocate() { _large.reallocate(); // deprecation } }
Comment #5 by andrei — 2016-05-30T14:36:41Z
(In reply to Martin Nowak from comment #4) > This is just an occurrence of wrong code caused by issue 314, b/c selective > imports weren't checked for visibility until recently. > > struct Bucketizer > { > import whatever : reallocate; // <- private > } > > struct Segregator(LargeAllocator) > { > LargeAllocator _large; > void reallocate() > { > _large.reallocate(); // deprecation > } > } The issue is subtler than that (I'd agree the snippet above is a clear cut). The thing is Bucketizer _also_ defines its own reallocate: struct Bucketizer { import whatever : reallocate; // <- private bool reallocate(ref void[] b, size_t size) // <- public { ... } } struct Segregator(LargeAllocator) { LargeAllocator _large; void reallocate() { _large.reallocate(); // deprecation } } The member "reallocate" should effectively hide the private import, yet the deprecation message still appears. Reopening, feel free to close if you can clarify.
Comment #6 by code — 2016-05-30T14:53:23Z
(In reply to Andrei Alexandrescu from comment #5) > The issue is subtler than that (I'd agree the snippet above is a clear cut). > The thing is Bucketizer _also_ defines its own reallocate: Ah, I was already wondering what was actually called now, but didn't have more time to investigate. > struct Bucketizer > { > import whatever : reallocate; // <- private > bool reallocate(ref void[] b, size_t size) // <- public > { ... } > > The member "reallocate" should effectively hide the private import, yet the > deprecation message still appears. It doesn't hide but overloads the selective import. Public/private overloads should have public visibility but will be access checked after overload resolution. Seems like the overload code https://github.com/dlang/dmd/blob/356353041c3d26d525e43f1ea6a9b36211ba523f/src/access.d#L481-L491 doesn't work properly.
Comment #7 by andrei — 2016-05-30T15:10:53Z
(In reply to Martin Nowak from comment #6) > (In reply to Andrei Alexandrescu from comment #5) > > The issue is subtler than that (I'd agree the snippet above is a clear cut). > > The thing is Bucketizer _also_ defines its own reallocate: > > Ah, I was already wondering what was actually called now, but didn't have > more time to investigate. > > > struct Bucketizer > > { > > import whatever : reallocate; // <- private > > bool reallocate(ref void[] b, size_t size) // <- public > > { ... } > > > > The member "reallocate" should effectively hide the private import, yet the > > deprecation message still appears. > > It doesn't hide but overloads the selective import. Public/private overloads > should have public visibility but will be access checked after overload > resolution. > Seems like the overload code > https://github.com/dlang/dmd/blob/356353041c3d26d525e43f1ea6a9b36211ba523f/ > src/access.d#L481-L491 doesn't work properly. Great, thanks!
Comment #8 by bugzilla — 2016-05-30T21:02:53Z
(In reply to Andrei Alexandrescu from comment #5) > struct Bucketizer > { > import whatever : reallocate; // <- private This is the equivalent of: alias reallocate = whatever.reallocate; meaning that the declaration is in the current scope, not the import scope. > The member "reallocate" should effectively hide the private import, yet the > deprecation message still appears. The private import is hidden. The alias is not.
Comment #9 by code — 2016-05-31T13:38:10Z
(In reply to Walter Bright from comment #8) > > The member "reallocate" should effectively hide the private import, yet the > > deprecation message still appears. > > The private import is hidden. The alias is not. Don't quite get that comment. Imports are private by default, so are the selectively imported symbol aliases. Already figured out what's wrong with the overload implementation in symbolIsVisible, just need to find time to fix it.
Comment #10 by bugzilla — 2016-07-09T10:12:00Z
(In reply to Martin Nowak from comment #9) > (In reply to Walter Bright from comment #8) > > > The member "reallocate" should effectively hide the private import, yet the > > > deprecation message still appears. > > > > The private import is hidden. The alias is not. > > Don't quite get that comment. Imports are private by default, so are the > selectively imported symbol aliases. import whatever : reallocate; // <- private This is the equivalent of: alias reallocate = whatever.reallocate; I.e. an actual alias is generated. The alias is not hidden. The import is. > Already figured out what's wrong with the overload implementation in > symbolIsVisible, just need to find time to fix it. Please don't fix until we agree on what the result should be.
Comment #11 by code — 2016-08-07T10:39:59Z
(In reply to Walter Bright from comment #10) > This is the equivalent of: > > alias reallocate = whatever.reallocate; > > I.e. an actual alias is generated. The alias is not hidden. The import is. It's a private alias b/c that's the protection of the import (implicitly). private import whatever : reallocate; equivalent to: private alias reallocate = whatever.reallocate; The bug that overloading this with a public alias causes an error should be reproducible for both cases.
Comment #12 by code — 2016-08-08T10:26:44Z
Comment #13 by github-bugzilla — 2016-08-09T10:08:34Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/22dc48171eaa3ef43dbec3e6bab6ea7fcb839a37 fix Issue 16085 - wrong visibility warning for overloaded alias symbol - mark OverDeclaration as overloadable - mark AliasDeclaration as overloadable (depends on aliasee) - replace overloadApply with a custom iteration b/c aliases must not be resolved for visibility checks (i.e. public aliases to private symbols are public) - deal with the messy overloading of aliasees (see comments) https://github.com/dlang/dmd/commit/8238ad782347330e0a822208c323a83d1d17ac64 Merge pull request #5847 from MartinNowak/fix16085 fix Issue 16085 - wrong visibility warning for overloaded alias symbol
Comment #14 by github-bugzilla — 2016-09-19T23:46:54Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/22dc48171eaa3ef43dbec3e6bab6ea7fcb839a37 fix Issue 16085 - wrong visibility warning for overloaded alias symbol https://github.com/dlang/dmd/commit/8238ad782347330e0a822208c323a83d1d17ac64 Merge pull request #5847 from MartinNowak/fix16085
Comment #15 by github-bugzilla — 2016-11-04T09:04:58Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/22dc48171eaa3ef43dbec3e6bab6ea7fcb839a37 fix Issue 16085 - wrong visibility warning for overloaded alias symbol https://github.com/dlang/dmd/commit/8238ad782347330e0a822208c323a83d1d17ac64 Merge pull request #5847 from MartinNowak/fix16085