File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -454,6 +454,23 @@ template to(T)
454454 assert (text(null ) == " null" );
455455}
456456
457+ // Test `scope` inference of parameters of `text`
458+ @safe unittest
459+ {
460+ static struct S
461+ {
462+ int * x; // make S a type with pointers
463+ string toString () const scope
464+ {
465+ static int g = 0 ; // force toString to be impure for:
466+ g++ ; // https://issues.dlang.org/show_bug.cgi?id=20150
467+ return " S" ;
468+ }
469+ }
470+ scope S s;
471+ assert (text(" a" , s) == " aS" );
472+ }
473+
457474// Tests for issue 11390
458475@safe pure /+ nothrow+/ unittest
459476{
@@ -4778,8 +4795,8 @@ private S textImpl(S, U...)(U args)
47784795 // assume that on average, parameters will have less
47794796 // than 20 elements
47804797 app.reserve (U.length * 20 );
4781-
4782- foreach (arg; args)
4798+ // Must be static foreach because of https://issues.dlang.org/show_bug.cgi?id=21209
4799+ static foreach (arg; args)
47834800 {
47844801 static if (
47854802 isSomeChar! (typeof (arg)) || isSomeString! (typeof (arg)) ||
Original file line number Diff line number Diff line change @@ -932,7 +932,8 @@ if (Ranges.length > 0 &&
932932 public :
933933 this (R input)
934934 {
935- foreach (i, v; input)
935+ // Must be static foreach because of https://issues.dlang.org/show_bug.cgi?id=21209
936+ static foreach (i, v; input)
936937 {
937938 source[i] = v;
938939 }
You can’t perform that action at this time.
0 commit comments