Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 22541 - DIP1000: Resolve ambiguity of ref-return-scope para… #13677

Merged
merged 1 commit into from
Feb 17, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/dmd/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ extern (C++) class FuncDeclaration : Declaration
* do existing practice. But we should examine how TypeFunction does
* it, for consistency.
*/
if (!tf.isref && isRefReturnScope(vthis.storage_class))
if (global.params.useDIP1000 != FeatureState.enabled &&
!tf.isref && isRefReturnScope(vthis.storage_class))
{
/* if `ref return scope`, evaluate to `ref` `return scope`
*/
Expand Down
16 changes: 16 additions & 0 deletions test/compilable/testsctreturn.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ void test()
size_t* p;
const ppi = const(PackedPtrImpl!(3))(p);
}

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

// issues.dlang.org/show_bug.cgi?id=22541

struct S
{
int i;
int* ptr;

int* wannabeReturnRef() scope return
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be marked @safe

{
return &i;
}
}