Bug 12604 – No "mismatched array lengths" error with narrowing conversions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-21T00:16:00Z
Last change time
2014-04-21T09:33:50Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2014-04-21T00:16:40Z
With the code, the initialization of 'a' and assignment of 'b' will cause two compile time errors. void main() { int[1] a = [1,2,3]; int[1] b; b = [1,2,3]; } ---- test.d(3): Error: mismatched array lengths, 1 and 3 test.d(4): Error: mismatched array lengths, 1 and 3 But if you replace 'int' with 'short', the compile-time errors will disappear. void main() { short[1] a = [1,2,3]; short[1] b; b = [1,2,3]; } Instead runtime exception is thrown. object.Error@(0): Array lengths don't match for copy: 3 != 1
Comment #1 by k.hara.pg — 2014-04-21T00:25:03Z
Comment #2 by github-bugzilla — 2014-04-21T09:33:50Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a833827fe1391a8a70fed84b6607e21c26c41da0 fix Issue 12604 - No "mismatched array lengths" error with narrowing conversions https://github.com/D-Programming-Language/dmd/commit/fbad0edc32b1fc1ff411dc0aaa83d796d13ff858 Merge pull request #3475 from 9rnsr/fix12604 Issue 12604 - No "mismatched array lengths" error with narrowing conversions