Arithmetic operator overloading result type should be the same as the operands #23194
Labels
Bug
This tag is applied to issues which reports bugs.
Operator Overload
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Type Aliases
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
Unit: Type System
Bugs/feature requests, that are related to the V types system.
Describe the bug
Arithmetic operations should remain associative and distributive. So A + B + C = D should be to valid in any case, to mention a simple example.
Current arithmetic operator overloading permits the result to be different from the operands. Problems:
Inconsistencies were mentioned already here: #23177
Reproduction Steps
Expected Behavior
A
Byte
whatever the value, truncated or even as an error when operation does not apply.Current Behavior
Possible Solution
Force result type to be the same of the operands.
Additional Information/Context
More complications:
Produces C error:
V version
V 0.4.8 00148d1
Environment details (OS name and version, etc.)
https://play.vlang.io/p/0b6cc9e21c
https://play.vlang.io/p/b09d63132f
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
Huly®: V_0.6-21631
The text was updated successfully, but these errors were encountered: