[Issue 12199] New: RedBlackTree problematic with non-string predicates
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 18 16:53:54 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12199
Summary: RedBlackTree problematic with non-string predicates
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: xinok at live.com
--- Comment #0 from Xinok <xinok at live.com> 2014-02-18 16:53:48 PST ---
DMD 2.064.2
Windows 7 x64
I've encountered a number of issues which are difficult to sum up in a single
bug report. Simply put, any code which uses functional/non-string predicates
with RedBlackTree is highly likely to fail to compile.
The following line compiles fine:
auto a = redBlackTree!("a < b", int)(10, 20, 30, 40, 50);
But attempt to substitute "a < b" with an equivalent static function:
bool pred(int a, int b){ return a < b; }
void main()
{
auto a = redBlackTree!(pred, int)(10, 20, 30, 40, 50);
}
Results in the compilation error:
std/container.d(6567): Error: pred (int a, int b) is not callable using
argument types ()
Things especially become problematic if you attempt to compile using unittests:
std/container.d(6567): Error: pred (int a, int b) is not callable using
argument types ()
std/container.d(5686): Error: function f38.pred (int a, int b) is not callable
using argument types ()
std/container.d(5960): Error: function f38.pred (int a, int b) is not callable
using argument types ()
std/container.d(6035): Error: function f38.pred (int a, int b) is not callable
using argument types ()
std/container.d(6081): Error: function f38.pred (int a, int b) is not callable
using argument types ()
std/container.d(6122): Error: function f38.pred (int a, int b) is not callable
using argument types ()
std/container.d(6243): Error: function f38.pred (int a, int b) is not callable
using argument types ()
std/container.d(6342): Error: function f38.pred (int a, int b) is not callable
using argument types ()
std/container.d(6575): Error: template instance
std.container.RedBlackTree!(int, pred) error instantiating /d665/f38.d(6):
instantiated from here: redBlackTree!(pred, int) /d665/f38.d(6): Error:
template instance std.container.redBlackTree!(pred, int) error instantiating
I think this line [1] shows how poorly written the unittests are. Attempting to
use any predicate other than "a < b" or "a > b" is likely to result in a
compiler or runtime error.
[1]
https://github.com/D-Programming-Language/phobos/blob/2.064/std/container.d#L5686
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list