Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 19, 2017 [Issue 15537] Private function is not accessible from other module when compiling with -debug flag | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15537 Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #1 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> --- The reason why this doesn't compile with -debug is mentioned briefly in the assumeSorted documentation: > In debug mode, a few random elements of r are checked for sortedness. -- https://dlang.org/library/std/range/assume_sorted.html Thus, std.range is failing to use your private compare function when attempting to perform this sortedness check. Note that even if the code compiled without -debug, the result would still not be useful, as you would not be able to pass the resulting SortedRange e.g. to std.algorithm.searching.find. It would fail with the same problem, being unable to access your private opCmp function. Whether symbols passed by alias parameter should be exempted from visibility checks is a separate matter. You can work around this problem by making the comparison function public, but also wrapping it inside a private struct: private struct Hidden { public static bool myCmp(Data a, Data b) { return a[0] < b[0]; } } auto bar() { return [Data(1, "one"), Data(2, "two")].assumeSorted!(Hidden.myCmp); } -- |
July 19, 2017 [Issue 15537] Private function is not accessible from other module when compiling with -debug flag | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15537 Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|dmd |phobos -- |
July 19, 2017 [Issue 15537] Private function is not accessible from other module when compiling with -debug flag | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15537 --- Comment #2 from Roman <freeslave93@gmail.com> --- (In reply to Vladimir Panteleev from comment #1) > The reason why this doesn't compile with -debug is mentioned briefly in the assumeSorted documentation: > > > In debug mode, a few random elements of r are checked for sortedness. > > -- https://dlang.org/library/std/range/assume_sorted.html > > Thus, std.range is failing to use your private compare function when attempting to perform this sortedness check. > > Note that even if the code compiled without -debug, the result would still not be useful, as you would not be able to pass the resulting SortedRange e.g. to std.algorithm.searching.find. It would fail with the same problem, being unable to access your private opCmp function. > > Whether symbols passed by alias parameter should be exempted from visibility checks is a separate matter. > > You can work around this problem by making the comparison function public, but also wrapping it inside a private struct: > > private struct Hidden > { > public static bool myCmp(Data a, Data b) { > return a[0] < b[0]; > } > } > > auto bar() { > return [Data(1, "one"), Data(2, "two")].assumeSorted!(Hidden.myCmp); > } Back then I solved this issue by using named enum string variables. Both solutions are hacks for sure. I think the changes to the compiler are required. -- |
July 21, 2017 [Issue 15537] Private function is not accessible from other module when compiling with -debug flag | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15537 Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |DUPLICATE --- Comment #3 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> --- *** This issue has been marked as a duplicate of issue 15230 *** -- |
Copyright © 1999-2021 by the D Language Foundation