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

checker: disallow indexing mut struct, when using as parameters #19992

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

shove70
Copy link
Contributor

@shove70 shove70 commented Nov 25, 2023

  1. make an error for indexing the mut struct
  2. Add tests.

Currently, zz &MyStruct and zz[0] V give a warning:

warning: pointer indexing is only allowed in `unsafe` blocks

but mut zz MyStruct and zz[0] do not

@Delta456
Copy link
Member

Is this PR co-related to #19949?

@spytheman
Copy link
Member

Is this PR co-related to #19949?

afaik no

@shove70 shove70 changed the title checker: add an unsafe block required notice when indexing the mut struct checker: disallow indexing mut struct, when using as parameters Nov 26, 2023
@shove70
Copy link
Contributor Author

shove70 commented Nov 27, 2023

afaik no

yep, almost no :)

@spytheman spytheman merged commit b9a7de5 into vlang:master Nov 27, 2023
54 checks passed
@shove70 shove70 deleted the struct_index branch November 27, 2023 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants