unsafe
can modify pub const
strings and arrays in other modules: is not good.
#23582
Labels
Bug
This tag is applied to issues which reports bugs.
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Describe the bug
unsafe
code can modify others modules'pub const
(variables in fact), including strings and fixed arrays. Don't know if is a bug or feature, but actual code can modify even the V library as important astime
and others. Other's people libraries in purpose or by mistake can modify expectations in V library or other libraries. We don't wantpi
constant changes!Reproduction Steps
Next program shows how
time
module "constants" are modified and the results before and after for the same time calls give different results.Produces
Expected Behavior
Prevent
unsafe
code can modifyconst
values.As a comparison, currently
unsafe
can't modify private nor immutable fields of other modules nor the size of arrays. Thoughunsafe
can modify local variables declared notmut
.Current Behavior
unsafe
code can modify constants defined in the V library:Possible Solution
unsafe
modify the constants.Additional Information/Context
No response
V version
V 0.4.9 c225e04
Environment details (OS name and version, etc.)
https://play.vlang.io/p/50eb44d1e0
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: