Bug 8843 – Statically known slices given as fixed-size array arguments

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-17T15:43:00Z
Last change time
2013-07-27T23:37:52Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-10-17T15:43:41Z
void foo(ref int[4] data) {} void bar(in ref int[4] data) {} void main() { auto a = new int[10]; foo(a[0 .. 4]); bar(a[0 .. 4]); } dmd 2.061alpha shows that currently that code is not accepted: test.d(5): Error: function test.foo (ref int[4u] data) is not callable using argument types (int[]) test.d(5): Error: cannot implicitly convert expression (a[0u..4u]) of type int[] to int[4u] test.d(6): Error: function test.bar (ref const(int[4u]) data) is not callable using argument types (int[]) test.d(6): Error: cannot implicitly convert expression (a[0u..4u]) of type int[] to const(int[4u]) But I think that code is worth accepting, when the slice width is known at compile-time. See also Issue 8838
Comment #1 by yebblies — 2013-07-27T23:37:52Z
*** This issue has been marked as a duplicate of issue 3652 ***