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

Allow 'ref readonly struct' for 'readonly ref struct' #25187

Closed
mazhou-msft opened this issue Mar 2, 2018 · 7 comments
Closed

Allow 'ref readonly struct' for 'readonly ref struct' #25187

mazhou-msft opened this issue Mar 2, 2018 · 7 comments
Labels
Area-Language Design Resolution-Duplicate The described behavior is tracked in another issue

Comments

@mazhou-msft
Copy link

Version Used:
Visual Studio 2017 27428.0.d15.7

Steps to Reproduce:

  1. Create a C# project for netcoreapp2.1
  2. Write a declaration of a ref struct:
public readonly ref struct S { }

Expected Behavior:
The order of 'ref' and 'readonly' should not matter; I can either use 'readonly ref struct' or 'ref readonly struct' to declare readonly ref-like types.

Actual Behavior:
'ref readonly struct' is not allowed. looks like ref struct is a compound keyword like partial class.

@CyrusNajmabadi
Copy link
Member

This is not a compiler issue, but a request for a change in the language. as such, this should be filed over at dotnet/csharplang. Thanks!

@alrz
Copy link
Contributor

alrz commented Mar 2, 2018

this is already championed (dotnet/csharplang#946)

@jcouv
Copy link
Member

jcouv commented Mar 3, 2018

Thanks for reporting this.
Since this is a known issue, I'll go ahead and close as duplicate. @alrz is close to getting this fix (#23533) into C# 7.3.

@jcouv jcouv closed this as completed Mar 3, 2018
@jcouv jcouv added Resolution-Duplicate The described behavior is tracked in another issue Area-Language Design labels Mar 3, 2018
@gafter
Copy link
Member

gafter commented May 17, 2018

This was not championed or fixed. What was fixed was the ordering of ref and partial. There is still an issue with the ordering of ref and readonly.

@gafter
Copy link
Member

gafter commented May 17, 2018

Issue moved to dotnet/csharplang #1536 via ZenHub

@alrz
Copy link
Contributor

alrz commented May 17, 2018

@gafter readonly is already permitted with any order. I believe this is exacly what is discussed earlier (allowing ref readonly struct)

@alrz
Copy link
Contributor

alrz commented May 17, 2018

that is, if we relax the order of ref the code in the title would compile fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Language Design Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

5 participants