msoucy / dproto

D Protocol Buffer mixins to create structures at compile time
Boost Software License 1.0
37 stars 16 forks source link

opGet() needed on RepeatedBuffer for use with std.algorithm.remove #21

Closed Kelet closed 10 years ago

Kelet commented 10 years ago

The title is overly specific, but I'm not sure of the concrete implications. The comments line is what I'd expect, whereas the noncommented line before it is what works currently.

import std.algorithm;
import dproto.dproto;

mixin ProtocolBufferFromString!"
    message Msg
    {
        repeated uint32 aggr = 1;
    }
";

void main()
{
    Msg msg;
    msg.aggr = [1, 2, 3, 4, 5];
    // msg.aggr = msg.aggr.remove(0);
    msg.aggr = msg.aggr.opGet().remove(0);
    assert(msg.aggr == [2, 3, 4, 5]);
}

Error message with the commented line instead of the noncommented line:

Compiling...
source\app.d(15): Error: template std.algorithm.remove does not match any function template declaration.
 Candidates are:
c:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7562):        std.algorithm.remove(SwapStrategy s
 = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s != SwapStrategy.stable && isBidirectionalRange!Range && hasLength!Range && Offset.length >= 1)
c:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7630):        std.algorithm.remove(SwapStrategy s
 = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s == SwapStrategy.stable && isForwardRange!Range && Offset.length >= 1)
c:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(7742):        std.algorithm.remove(alias pred, SwapStrategy s = SwapStrategy.stable, Range)(Range range) if (isBidirectionalRange!Range)
source\app.d(15): Error: template std.algorithm.remove(SwapStrategy s = SwapStrategy.stable, Range, Offset...)(Range range, Offset offset) if (s != SwapStrategy.stable && isBidirectionalRange!Range && hasLength!Range && Offset.length >= 1) cannot deduce template function from argument types !()(RepeatedBuffer!(1, "uint32", uint, false, false), int)
Error executing command run: DMD compile run failed with exit code 1
Kelet commented 10 years ago

Minimal case: http://dpaste.dzfl.pl/ceec8f9a

Works in 2.063, does not work in 2.064. I'll try to figure out if it was intended or is a regression. I don't immediately see anything on the changelog related to this.

Kelet commented 10 years ago

According to a regression test, it is caused by this commit: https://github.com/D-Programming-Language/phobos/pull/1162/files

msoucy commented 10 years ago

The issue filed on the D bugzilla was marked as invalid - will not be fixed due to alias this not making the entire wrapped class a forward range. I'll be working on this hopefully tonight.

msoucy commented 10 years ago

Seems to be fixed in 8af90832d3125