Skip to content

Commit 134e565

Browse files
committed
Don't show slicing in array literal section, just link to it
1 parent 285a29b commit 134e565

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

spec/expression.dd

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,37 +1716,15 @@ $(GNAME ArrayMemberInitialization):
17161716
---
17171717

17181718
$(P By default, an array literal is typed as a dynamic array, but the element
1719-
count is known at compile time. So all array literals can be
1720-
implicitly converted to static array types. Slicing a dynamic array with
1721-
statically known bounds also allows conversion to a static array.)
1719+
count is known at compile time. So an array literal can be
1720+
implicitly converted to a static array of the same length.)
17221721

1723-
$(SPEC_RUNNABLE_EXAMPLE_RUN
17241722
-------------
1725-
void foo(long[2] a)
1726-
{
1727-
assert(a == [2, 3]);
1728-
}
1729-
void bar(ref long[2] a)
1730-
{
1731-
assert(a == [2, 3]);
1732-
a = [4, 5];
1733-
assert(a == [4, 5]);
1734-
}
1735-
1736-
void main()
1737-
{
1738-
long[] arr = [1, 2, 3];
1739-
1740-
foo(arr[1 .. 3]);
1741-
assert(arr == [1, 2, 3]);
1742-
1743-
bar(arr[1 .. 3]);
1744-
assert(arr == [1, 4, 5]);
1745-
1746-
//foo(arr[0 .. 3]); // cannot match length
1747-
}
1723+
int[2] sa = [1, 2];
17481724
-------------
1749-
)
1725+
1726+
$(NOTE Slicing a dynamic array with statically known bounds also
1727+
$(RELATIVE_LINK2 slice_to_static_array, allows conversion) to a static array.)
17501728

17511729
$(P If any $(I ArrayMemberInitialization) is a
17521730
$(DDSUBLINK spec/template, TemplateParameterSequence, ValueSeq),

0 commit comments

Comments
 (0)