fsprojects / Chessie

Railway-oriented programming for .NET
http://fsprojects.github.io/Chessie/
The Unlicense
188 stars 43 forks source link

LINQ extension method `SelectMany` yields duplicated messages #26

Closed battermann closed 8 years ago

battermann commented 8 years ago

The LINQ extension method SelectMany yields duplicated messages when the LINQ query syntax is used as this test shows:

[Test]
public void Test()
{
    Func<Result<string, string>> f = () => 
        from a in Result<string, string>.FailWith("fail")
        from b in Result<string, string>.Succeed("succeed")
        from c in Result<string, string>.Succeed("succeed")
        select a + b + c;

    f().Match(
        ifSuccess: (s, list) => Assert.Fail(),
        ifFailure: list => Assert.That(list, Is.EquivalentTo(new[] { "fail" })));
}

The test fails with this message:

Expected: equivalent to < "fail" >  But was:  < "fail", "fail", "fail", "fail" >