Bug 13700 – Rejected valid conversion from slice to fixed size array

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-08T13:15:37Z
Last change time
2024-12-13T18:33:04Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18906 →

Comments

Comment #0 by bearophile_hugs — 2014-11-08T13:15:37Z
I think this whole program should be accepted: void main() { int[char[2]] aa; string s = "hello"; immutable i = 1; aa[s[i .. i + 2]] = 1; // OK auto j = 1; aa[s[j .. j + 2]] = 1; // Error char[2] aux = s[j .. j + 2]; aa[aux] = 1; // OK } DMD 2.067alpha gives: test.d(7,9): Error: cannot implicitly convert expression (s[cast(uint)j..cast(uint)(j + 2)]) of type string to char[2]
Comment #1 by k.hara.pg — 2014-12-10T08:51:58Z
Comment #2 by k.hara.pg — 2014-12-10T09:00:15Z
(In reply to Kenji Hara from comment #1) > https://github.com/D-Programming-Language/dmd/pull/4209 Handle following slice forms: arr[e1-b .. e2] (length = a) arr[e1 .. e2+b] (length = b) arr[e1-a .. e2+b] (length = a + b) arr[e1+a .. e2+b] (length = b - a, if a <= b) arr[e1-a .. e2-b] (length = a - b, if a >= b) Requires: 1. 'e1' and 'e2' are equivalent expression that have no side effects. 2. 'a' and 'b' are (const-folded) constants.
Comment #3 by github-bugzilla — 2015-01-11T04:22:28Z
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/b6765d4729ddefaa607cc0af39e9fd74305ebd76 Issue 13700 - Rejected valid conversion from slice to fixed size array https://github.com/D-Programming-Language/dlang.org/commit/603afb6809eae00f4c48ccc8a1e435242e2b9f0b Merge pull request #727 from 9rnsr/fix13700 Issue 13700 - Rejected valid conversion from slice to fixed size array
Comment #4 by dkorpel — 2024-01-08T10:38:52Z
*** Issue 24323 has been marked as a duplicate of this issue. ***
Comment #5 by robert.schadek — 2024-12-13T18:33:04Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18906 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB