-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
reset
instances not be accessible for requiresInit
types
#22898
Comments
Okay, I will fix #22883 differently but keep the better codegen change. |
this makes sense, but this is truly a language problem - it should not have allowed you to make the fix this way to begin with ;) |
No... |
well, can't have both: either |
That's just your usual "no middle-ground allowed" opinion which is unworkable. In reality effectively every type that benefits from |
that's fine as long as it's enforced by the compiler, which is the point of requiresInit and of this issue |
escape hatches are also fine if the code using them maintains the invariants through other means, but allowing the public reset function to break Also, as a user of a library, I cannot know if it calls reset in a safe way or not generally - that's why "can simply not use reset" doesn't work: it requires the kind of deep inspection that the compiler does but is infeasible otherwise. |
One possible solution could be to add a |
Description
This snippet defeats the purpose of
requiresInit
- ie it should not be possible to access the "default"-initialized state of arequiresInit
-based object meaning that afterreset
the variable must no longer be observable orreset
must give an error for such types - related to #22895 - the "fix" might cause better codegen but semantically is still unsound.Nim Version
devel
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: