You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when taking a pointer to an element of a mutable array, adding extra parenthesis sidesteps safety check
Reproduction Steps
mutarr:= [1, 2, 3]
mutptr1:=&(arr[1]) // <- this should error, but it doesn'tmutptr2:=&arr[1] // <- this errors, unless put inside unsafe block
Expected Behavior
the checker should catch this
Current Behavior
the checker ignores it
Possible Solution
No response
Additional Information/Context
there's already a check in place for the exact situation, but it is sidestepped with added parenthesis. my attempts at dump debugging show that in this case typ_sym is treated like an immutable value rather than a mutable array
Interesting. Seems required unsafe you are mentioning "tries" to protect the mutable array reference and the extra parentheses are doing the same. But using the reference later is more interesting. The reference (does not need to be mutable) can be used as argument of a function where the value referenced can be modified with unsafe de-reference *.
But unsafe de-reference is more powerful than V mutability because the array does not need to be mutable, the reference does not need to be surrounded with unsafe and finally the inmutable array can be mutated.
In next example both arrays mutable a and immutable `b are modified:
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
when taking a pointer to an element of a mutable array, adding extra parenthesis sidesteps safety check
Reproduction Steps
Expected Behavior
the checker should catch this
Current Behavior
the checker ignores it
Possible Solution
No response
Additional Information/Context
there's already a check in place for the exact situation, but it is sidestepped with added parenthesis. my attempts at dump debugging show that in this case
typ_sym
is treated like an immutable value rather than a mutable arrayV version
V 0.4.10 52c7130
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: