-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
checker: add checks for operator overloading #7737
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
checker: add checks for operator overloading #7737
Conversation
vlib/v/checker/checker.v
Outdated
| receiver_sym := c.table.get_type_symbol(node.receiver.typ) | ||
| param_sym := c.table.get_type_symbol(node.params[1].typ) | ||
| if receiver_sym.name != param_sym.name || | ||
| param_sym.kind !in [.struct_, .alias] || receiver_sym.kind !in [.struct_, .alias] { |
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.
I had to add a check for .alias due to C interpolation in math.big module.
vlib/v/checker/checker.v
Outdated
| c.error('operator methods are only allowed for struct and type alias', | ||
| node.pos) | ||
| } else { | ||
| if param_sym.name != receiver_sym.name { |
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.
if node.receiver.typ != node.params[1].typ {
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.
Thanks! It is much better!
|
Good job @Delta456 |
No description provided.