[Issue 15537] Private function is not accessible from other module when compiling with -debug flag

2017-07-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15537

Vladimir Panteleev  changed:

   What|Removed |Added

 Resolution|INVALID |DUPLICATE

--- Comment #3 from Vladimir Panteleev  ---


*** This issue has been marked as a duplicate of issue 15230 ***

--


[Issue 15537] Private function is not accessible from other module when compiling with -debug flag

2017-07-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15537

--- Comment #2 from Roman  ---
(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.

--


[Issue 15537] Private function is not accessible from other module when compiling with -debug flag

2017-07-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15537

Vladimir Panteleev  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Vladimir Panteleev  ---
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);
}

--


[Issue 15537] Private function is not accessible from other module when compiling with -debug flag

2017-07-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15537

Vladimir Panteleev  changed:

   What|Removed |Added

  Component|dmd |phobos

--