-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
v: fix mutable option #19100
base: master
Are you sure you want to change the base?
v: fix mutable option #19100
Conversation
|
@@ -113,6 +113,7 @@ pub enum TypeFlag { | |||
generic | |||
shared_f | |||
atomic_f | |||
option_mut_param_t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need that? mut
is usually just a modifier, not something that is part of the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeFlags are limited to just 3 bits, i.e. just 8 combinations :-|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joe-conigliaro can you please also review this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need that?
mut
is usually just a modifier, not something that is part of the type.
Yes. I was thinking a way to determine when an option ptr must be used as struct _option_*_ptr
or a real pointer.
The CI is passing, can it be reviewed/merged now? |
It was missing a parameter validation, checking if everything is ok yet. |
Fix #18818
🤖 Generated by Copilot at 7d84ddf
This pull request fixes the C code generation for option types that are passed as mutable parameters to functions. It adds a new type flag
option_mut_param_t
to mark these types and adjusts the C type names, assignments, and string representations accordingly. It also fixes some bugs in the code generation for option expressions and function calls.🤖 Generated by Copilot at 7d84ddf
option_mut_param_t
to mark option types that are passed as mutable parameters or return values (link)memcpy
to copy the right expression to thedata
field of the option struct in assignments (link, link, link)dump_expr
method, which is used for debugging and error reporting (link)parse_param
andparse_return_type
methods invlib/v/parser/fn.v
to set theoption_mut_param_t
flag on option types without any pointer modifiers (link, link)gen_option_type
method invlib/v/gen/c/cgen.v
, since they are already handled by theoption_mut_param_t
flag (link)