This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
rule that all structures with more than 8 fields are always passed as reference in methods should be removed #17077
Labels
Bug
This tag is applied to issues which reports bugs.
Feature Request
This issue is made to request a feature.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
Weird/Undocumented Behaviour
This issue is related to a bug, that was surprising and wasted user's time.
Describe the feature
This rule sounds as strange as possible, and what is most terrible, it is IMPLICIT and NOT DESCRIBED in the documentation.
I don't see the point in this rule because the developer can decide YOURSELF when the structure should be passed as reference or not.
Moreover, adding a new field to the structure completely changes the receiver's pass logic, which can be dangerous.
The compiler SHOULD NOT show off one's "intelligence" and add IMPLICITIES.
Example:
https://play.vlang.io/?query=06bda73b49 (8 fields)
All ok, different pointers because the receiver doesn't have a pointer type
https://play.vlang.io/p/88dc100004 (9 fields)
Not ok, same pointers.
Compiler code:
v/vlib/v/parser/fn.v
Line 646 in 865c0ea
Use Case
Proposed Solution
Remove this rule.
Other Information
No response
Acknowledgements
Version used
V 0.3.2 89aa695.865c0ea
Environment details (OS name and version, etc.)
The text was updated successfully, but these errors were encountered: