Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/escape.d
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,11 @@ private void escapeByValue(Expression e, EscapeByResults* er)
}
Type t1b = e.e1.type.toBasetype();
if (t1b.ty == Tsarray)
escapeByRef(e.e1, er);
{
Type tb = e.type.toBasetype();
if (tb.ty != Tsarray)
escapeByRef(e.e1, er);
}
else
e.e1.accept(this);
}
Expand Down
15 changes: 15 additions & 0 deletions test/fail_compilation/retscope.d
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,18 @@ int* escape6() @safe
return foo6(&b);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is not related, according to the P.R.'s title ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need to review #6321 first.


/***************************************************/

struct S7
{
int[10] a;
int[3] abc(int i) @safe
{
return a[0 .. 3]; // should not error
}
}

/***************************************************/

int[3] escape8(scope int[] p) @safe { return p[0 .. 3]; } // should not error
char*[3] escape9(scope char*[] p) @safe { return p[0 .. 3]; }