Bug 11181 – Missing compile-time error for wrong array literal

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-06T02:58:00Z
Last change time
2014-05-26T01:22:28Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-10-06T02:58:30Z
void main() { const string[][] a = [["a", "b"], "x"]; } DMD 2.064 alpha gives the right error: test.d(2): Error: incompatible types for ((["a", "b"]) : ("x")): 'string[]' and 'string' But: void main() { auto a = ["a", "b"]; const string[][] b = [a[0 .. $], "x"]; } Gives no compile-time errors, and gives at run-time: object.Error: array cast misalignment
Comment #1 by k.hara.pg — 2014-05-25T22:36:36Z
Comment #2 by github-bugzilla — 2014-05-26T01:22:28Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ba475fa0b81b1be89a84c983a65c14c2ddf76733 fix Issue 11181 - Missing compile-time error for wrong array literal https://github.com/D-Programming-Language/dmd/commit/832e87684fa04a0f29f2e515b0d1eb9a94943b67 Merge pull request #3583 from 9rnsr/fix11181 Issue 11181 - Missing compile-time error for wrong array literal