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

Compiler doesn't take readonly members into account for span safety rules #35146

Closed
tannergooding opened this issue Apr 19, 2019 · 3 comments · Fixed by #35597
Closed

Compiler doesn't take readonly members into account for span safety rules #35146

tannergooding opened this issue Apr 19, 2019 · 3 comments · Fixed by #35597
Assignees
Milestone

Comments

@tannergooding
Copy link
Member

The language currently disallows you from passing a Span<T> to an instance method of a ref struct, unless that ref struct is also readonly or an in extension method.

The compiler should presumably also take into consideration whether a given member is itself readonly on a mutable instance struct and allow that as well.

For reference: https://sharplab.io/#v2:EYLgtghgzgLgpgJwDQxASwDYB8ACAGAAhwEYBuAWACgcBmAhOCAEwHsA7DAT3rgDMDYCAK4BjGAQDKAHgAqAPgIBvKgVVE6OACwEAsgAoJABwhtZCgB4BKFWuWU1BAL5VnlKrR79Bo8RIBMZko2qh4MzOxcRNr6RiaBVsFB9mquru4axABsRH4EAMJUdg4eQmxQELxwRFlRBAByBlLAnPAKwNbJqkUOarGmAEItcBYEALwCMBAiANYQGBgsIgTN8ADaAKwAuhSdPcAAdPpWOw6uDoklZRVVJNla9QYBK8PLHQ7dPZLGA0Mj47BTWbzRbLIYbbaJBwAeihBAAouZDHAxHAmAQYCwCAB3FgIaZIARoNgiKr6SwENBQAgmNgsSbwNEYgi08RgIT0qowAAWVSJAOJcCQkLUMOpbEZPIYvFxVREJgA5OJYDKCOZhaoDkdLCcUi4gA

@tannergooding
Copy link
Member Author

CC. @RikkiGibson, @jaredpar

@tannergooding
Copy link
Member Author

Rikki suggested I also tag @VSadov, offline.

@jcouv jcouv added this to the 16.1 milestone Apr 19, 2019
@RikkiGibson RikkiGibson self-assigned this Apr 22, 2019
@RikkiGibson
Copy link
Contributor

When I first heard this I thought it was related to #34487 but it looks like spilling is not involved. So the fix shouldn't be too complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants