-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
VS 17.3 Preview 3 Regression from Preview 2 with ref-returning an out parameter #62900
Comments
This should also be by design as per the latest draft of the lowlevel struct improvements proposal (see https://github.com/dotnet/csharplang/blob/main/proposals/low-level-struct-improvements.md). |
@Sergio0694 |
It should be possible to use |
@cston Thank you for your suggestion, but now I get a different compile error: |
I think for the same reason public static ref TTo AsRef<TFrom, TTo>(this ref TFrom it, out TTo v)
where TFrom : struct
{
ref TTo to = ref Unsafe.As<TFrom, TTo>(ref it);
v = to;
return ref to;
} |
@Sergio0694 Thank you for your suggested workaround. Yes, I thought about it, but was concerned about the performance hit of assigning to an intermediate variable. I guess it is still acceptable as a workaround. Though I still don't get how come it worked with the previous VS preview and no longer works with latest VS preview, thus seemingly breaking backwards-compat, as I did not change the DotNet SDK version at all - only updated VS. |
17.3 preview 3 added support for declaring The previous behavior can be enabled by compiling with |
@cston Just to clarify then: once
... is not really a good option since signature change is required and all the call sites need to be changed in an unwanted way, i.e. inability to declare and |
There is no performance hit. There's no variable either. All of that will be enregistered anyway (see here). |
Yes, adding I have updated the breaking change documentation, and added that as a better work around, as part of the PR to support |
@cston Do you want to keep this issue open to capture this as a test case for |
Version Used:
VS 2022 17.3 Preview 3
VS 2022 17.3 Preview 3 Regression Error:
VS 2022 17.3 Preview 2 or earlier:
Expected Behavior: Should work the same as in VS 17.3 Preview 2 or earlier: an
out
parameter should be ref-returnable.Actual Behavior: Since VS 17.3 Preview 3: cannot return a parameter by reference 'v' because it is not a ref parameter
The text was updated successfully, but these errors were encountered: