Bug 10179 – Tuple assignment should not cause "has no effect" error even if the length is zero

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-26T20:35:00Z
Last change time
2013-05-27T06:19:25Z
Keywords
pull
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2013-05-26T20:35:32Z
Currently zero-length tuple assignment would cause "has no effect" error. struct S {} void main() { S s; static assert(s.tupleof.length == 0); s.tupleof = s.tupleof; // error } This is basically not bad, but in generic code this behavior requires additional length check. struct S(Types...) { Types field; void set(S rhs) { //field = rhs.field; // --> When Types.length == 0, "has no effect" error occurs. // Workaround static if (Types.length > 0) // additional check field = rhs.field; } } void main() { S!(int, long) s1; s1.set(s1); S!() s2; s2.set(s2); } So I think that stop reporting "has no effect" error for tuple assignment is small but useful improvement.
Comment #1 by k.hara.pg — 2013-05-26T22:34:30Z
Comment #2 by github-bugzilla — 2013-05-27T06:19:05Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1a5c0e6f01a78a501782d1f511e0f68d85b36d6f fix Issue 10179 - Tuple assignment should not cause "has no effect" error even if the length is zero https://github.com/D-Programming-Language/dmd/commit/ccfdf10f50e76ae93986619190a542da565388f7 Merge pull request #2084 from 9rnsr/fix10179 [enh] Issue 10179 - Tuple assignment should not cause "has no effect" error even if the length is zero