Bug 5193 – SList cannot have struct elements that have immutable members.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2010-11-09T06:46:00Z
Last change time
2011-12-03T07:03:30Z
Keywords
patch
Assigned to
andrei
Creator
zan77137

Comments

Comment #0 by zan77137 — 2010-11-09T06:46:42Z
I think this code should be able to work. -------- main.d -------- import std.container; struct Data { const int val; } void main() { SList!Data list; } -------- Result -------- $ dmd -run main ..\std\container.d(941): Error: can only initialize c onst member _payload inside constructor ------------------------
Comment #1 by chuck.sonic — 2010-11-19T09:35:14Z
WARNING: N00B ALERT! Similar issues with Array and/or SList initializer? Similar but slightly different: -------- main.d -------- import std.container; void main() { auto aList = Array!string(); } -------- Result -------- $ dmd -run main /opt/dmd2/bin/../../src/phobos/std/container.d(1536): Error: this for _data needs to be type Array not type Payload /opt/dmd2/bin/../../src/phobos/std/container.d(1537): Error: this for _data needs to be type Array not type Payload /opt/dmd2/bin/../../src/phobos/std/container.d(1538): Error: this for _data needs to be type Array not type Payload ------------------------ Different but slightly similar: -------- main.d -------- import std.container; void main() { auto s = SList!string("hello"); } -------- Result -------- $ dmd -run main main.d(5): Error: template std.container.SList!(string).SList.__ctor(U) if (isImplicitlyConvertible!(U,T)) does not match any function template declaration main.d(5): Error: template std.container.SList!(string).SList.__ctor(U) if (isImplicitlyConvertible!(U,T)) cannot deduce template function from argument types !()(string) ------------------------
Comment #2 by k.hara.pg — 2011-10-28T07:44:22Z
Comment #3 by k.hara.pg — 2011-12-03T07:03:30Z