v: fix mutable option#19100
Conversation
|
|
| generic | ||
| shared_f | ||
| atomic_f | ||
| option_mut_param_t |
There was a problem hiding this comment.
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.
TypeFlags are limited to just 3 bits, i.e. just 8 combinations :-|
There was a problem hiding this comment.
@joe-conigliaro can you please also review this?
There was a problem hiding this comment.
Do you really need that?
mutis 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. |
|
Closing for inactivity. |
|
Lack of running |
|
Is it ready for review now? |
Yes. |
Co-authored-by: JalonSolov <JalonSolov@gmail.com>
Fix #18818
Fix #24622
Fix #24101
🤖 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_tto 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_tto mark option types that are passed as mutable parameters or return values (link)memcpyto copy the right expression to thedatafield of the option struct in assignments (link, link, link)dump_exprmethod, which is used for debugging and error reporting (link)parse_paramandparse_return_typemethods invlib/v/parser/fn.vto set theoption_mut_param_tflag on option types without any pointer modifiers (link, link)gen_option_typemethod invlib/v/gen/c/cgen.v, since they are already handled by theoption_mut_param_tflag (link)