[Issue 12569] New: Better error message for std.algorithm.reduce used with two functions and a scalar seed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Apr 12 15:44:05 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12569
Issue ID: 12569
Summary: Better error message for std.algorithm.reduce used
with two functions and a scalar seed
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Keywords: diagnostic
Severity: normal
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
This code compiles:
void main() {
import std.algorithm: min, max, reduce;
import std.typecons: tuple;
dchar c = 'a';
reduce!(min, max)(tuple(c, c), "hello"); // OK
}
But here I have forgotten to use a 2-tuple as seed for reduce:
void main() {
import std.algorithm: min, max, reduce;
import std.typecons: tuple;
dchar c = 'a';
reduce!(min, max)(c, "hello"); // error
}
DMD 2.066alpha gives an error inside std.algorithm, but I think it's better to
add a template constraint to std.algorithm.reduce or a static if to guard
against this mistake:
...\dmd2\src\phobos\std\algorithm.d(772,45): Error: no property 'Types' for
type 'dchar'
test.d(5,22): Error: template instance std.algorithm.reduce!(min,
max).reduce!(dchar, string) error instantiating
--
More information about the Digitalmars-d-bugs
mailing list