July 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8367

           Summary: std.range.chain's template constraint is inadequate
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: jmdavisProg@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-07-10 00:18:01 PDT ---
This code fails to compile

import std.algorithm;
import std.range;

struct Foo {}

void main()
{
    auto f = Foo();
    auto foos = [f];
    auto foo = foos.map!(x => "foo");
    auto bar = foo.chain("bar");
}

giving this string of errors:

/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(1934): Error: cannot
have parameter of type void
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(1934): Error:
variable std.range.chain!(Result,string).chain.Result.fixRef.val variables
cannot be of type void
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(1936): Error: cannot
return non-void from void function
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(1996): Error:
function std.range.chain!(Result,string).chain.Result.fixRef (void val) is not
callable using argument types (string)
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(1996): Error: cannot
implicitly convert expression (this.source._field_field_0.front()) of type
string to void
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(1996): Error:
function std.range.chain!(Result,string).chain.Result.fixRef (void val) is not
callable using argument types (dchar)
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(1996): Error: cannot
implicitly convert expression (front(this.source._field_field_1)) of type dchar
to void
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2026): Error: cannot
return non-void from void function
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2026): Error: cannot
return non-void from void function
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2039): Error:
function std.range.chain!(Result,string).chain.Result.fixRef (void val) is not
callable using argument types (dchar)
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2039): Error: cannot
implicitly convert expression (back(this.source._field_field_1)) of type dchar
to void
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2039): Error:
function std.range.chain!(Result,string).chain.Result.fixRef (void val) is not
callable using argument types (string)
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2039): Error: cannot
implicitly convert expression (this.source._field_field_0.back()) of type
string to void
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2061): Error: cannot
return non-void from void function
/home/jmdavis/dmd2/linux/bin/../../src/phobos/std/range.d(2061): Error: cannot
return non-void from void function
q.d(11): Error: template instance std.range.chain!(Result,string) error
instantiating

The code shouldn't compile. It's trying to chain an array of strings and a string. The types don't match. However, the error is _horrible_. Since the given arguments won't compile with chain, they shouldn't pass chain's template constraint (either that or chain must have a series of static asserts which output informative error messages for types which won't work with chain). But obviously, chain's template constraint is passing with arguments which fail to compile with chain, and that needs to be fixed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8367



--- Comment #1 from github-bugzilla@puremagic.com 2013-01-08 23:07:31 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/1008da752b135e41e26bc9fedeaffe824046be4e Issue 8367 - Insufficient constraints for chain

The error message from compiling the bug's sample code after this change is:

```
bug.d(11): Error: template std.range.chain does not match any function template
declaration. Candidates are:
std/range.d(2018):        std.range.chain(Ranges...)(Ranges rs) if
(Ranges.length > 0 && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) &&
!is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void))
bug.d(11): Error: template std.range.chain(Ranges...)(Ranges rs) if
(Ranges.length > 0 && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)) &&
!is(CommonType!(staticMap!(ElementType, staticMap!(Unqual, Ranges))) == void))
cannot deduce template function from argument types !()(MapResult!(__lambda2,
Foo[]),string)
```

Fixes Issue 8367 http://d.puremagic.com/issues/show_bug.cgi?id=8367

https://github.com/D-Programming-Language/phobos/commit/ca44a116d5cad084fe1cb968f23c54059984a06e Merge pull request #1047 from Poita/bug8367

Issue 8367 - Insufficient constraints for chain

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8367


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home