Bug 18824 – [REG 2.080] Tuple's opBinaryRight takes precedence over appending a tuple to an array of tuples
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-05-04T09:42:39Z
Last change time
2018-12-24T19:21:54Z
Assigned to
Eduard Staniloiu
Creator
Mitu
Comments
Comment #0 by the.mail.of.mi2 — 2018-05-04T09:42:39Z
This code fails to compile:
import std.stdio;
import std.typecons;
alias Type = Tuple!(int, string);
void main()
{
Type[] arr;
arr = arr ~ tuple(2, "s");
writeln(arr);
}
Message:
onlineapp.d(8): Error: cannot implicitly convert expression tuple(2, "s").opBinaryRight(arr) of type Tuple!(Tuple!(int, string)[], int, string) to Tuple!(int, string)[]
I can't see anything in changelog that could be related to this, thus I expect it's a regression.
Comment #1 by Marco.Leise — 2018-05-06T17:28:55Z
I think the component should be "Phobos". I met the same issue, but were coming from a ternary operator:
enum foo() {
import std.typecons;
Tuple!(string, size_t)[] parts;
return true ? parts ~ tuple("abc", size_t.max) : parts;
}
Message:
test.d(4): Error: incompatible types for (tuple("abc", 18446744073709551615LU).opBinaryRight(parts)) : (parts): Tuple!(Tuple!(string, ulong)[], string, ulong) and Tuple!(string, ulong)[]
The changelog entries are probably:
Phobos enhancements
1. Bugzilla 4591: Concat of std.typecons.Tuples
https://issues.dlang.org/show_bug.cgi?id=4591
[…]
5. Bugzilla 14637: Array operations should work on tuples
https://issues.dlang.org/show_bug.cgi?id=14637