Skip to content

conform to return-ref-scope ordering #10782

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

Merged
merged 1 commit into from
May 22, 2025
Merged
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
8 changes: 4 additions & 4 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -10786,18 +10786,18 @@ private template replaceTypeInFunctionTypeUnless(alias pred, From, To, fun)
{
if (i)
result ~= ", ";
if (storageClasses[i] & ParameterStorageClass.return_)
result ~= "return ";
if (storageClasses[i] & ParameterStorageClass.scope_)
result ~= "scope ";
Comment on lines +10789 to 10792
Copy link
Contributor

Choose a reason for hiding this comment

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

Why put return under the scope instead of ref? That looks like a breaking change as return ref scope will now be translated to return scope by ReplaceTypeUnless. Although, it's not ideal either way when ParameterStorageClass doesn't know about the storage class order like the compiler does.

Copy link
Member Author

Choose a reason for hiding this comment

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

The design of this function is deficient because one cannot control the order of ref, return and scope. I did the best I could with it to keep it working with the unittests.

Copy link
Contributor

Choose a reason for hiding this comment

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

return ref and return scope should be distinct parameter storage classes, like in the compiler.

if (storageClasses[i] & ParameterStorageClass.in_)
result ~= "in ";
if (storageClasses[i] & ParameterStorageClass.out_)
result ~= "out ";
if (storageClasses[i] & ParameterStorageClass.ref_)
result ~= "ref ";
if (storageClasses[i] & ParameterStorageClass.in_)
result ~= "in ";
if (storageClasses[i] & ParameterStorageClass.lazy_)
result ~= "lazy ";
if (storageClasses[i] & ParameterStorageClass.return_)
result ~= "return ";

result ~= "PX[" ~ i.stringof ~ "]";
}
Expand Down
Loading