Bug 10784 – Cannot initialize Nullable std.typecons.Tuple!(float,"x",float,"y",float,"z")

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-08T16:54:53Z
Last change time
2018-10-16T18:18:13Z
Assigned to
No Owner
Creator
Mariusz GliwiƄski

Comments

Comment #0 by alienballance — 2013-08-08T16:54:53Z
http://dpaste.dzfl.pl/a968d7d1c As for my understanding, the code i pasted should work like: struct Coord { float x; float y; float z; } void main() { Nullable!Coord c = Coord(1f,2f,3f); } I'm sorry that i wont try to understand the reasons but i hope my bugreports are helping.
Comment #1 by monarchdodra — 2013-08-09T05:26:07Z
It looks like nullable's constructor is marked as inout, which makes the argument (in this case Tuple) marked as "const-qualified" in the body of the function. The assignment itself is still legal, but the template constraint "areCompatibleTuples" seems to be choking because of it. I think. Either that, or it's this line in areCompatibleTuples: auto result = mixin("lhs "~op~" rhs"); That "auto result =" is *partially* wrong: It was put there to check comparison operators, but it shouldn't be there for assignment operator. What I still need to investigate, is the interaction between both of these.
Comment #2 by n8sh.secondary — 2018-10-16T18:18:13Z
Checked example code with DMD v2.082.1 and it's currently working. --- import std.typecons; alias Tuple!(float, "x", float, "y", float, "z") Coord; void main() { Nullable!Coord c = Coord(1f,2f,3f); } ---