1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: allow all binary operations when translating code produced by c2v (#13964)

This commit is contained in:
playX 2022-04-07 13:22:24 +04:00 committed by GitHub
parent 4666a27e5f
commit 6a820c2845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -576,8 +576,8 @@ pub fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
left_right_pos := left_pos.extend(right_pos) left_right_pos := left_pos.extend(right_pos)
if left_type.is_any_kind_of_pointer() if left_type.is_any_kind_of_pointer()
&& node.op in [.plus, .minus, .mul, .div, .mod, .xor, .amp, .pipe] { && node.op in [.plus, .minus, .mul, .div, .mod, .xor, .amp, .pipe] {
if (right_type.is_any_kind_of_pointer() && node.op != .minus) if !c.pref.translated && ((right_type.is_any_kind_of_pointer() && node.op != .minus)
|| (!right_type.is_any_kind_of_pointer() && node.op !in [.plus, .minus]) { || (!right_type.is_any_kind_of_pointer() && node.op !in [.plus, .minus])) {
left_name := c.table.type_to_str(left_type) left_name := c.table.type_to_str(left_type)
right_name := c.table.type_to_str(right_type) right_name := c.table.type_to_str(right_type)
c.error('invalid operator `$node.op` to `$left_name` and `$right_name`', left_right_pos) c.error('invalid operator `$node.op` to `$left_name` and `$right_name`', left_right_pos)