diff --git a/vlib/v/ast/ast.v b/vlib/v/ast/ast.v index 5afaf2c04d..d86c5b9d86 100644 --- a/vlib/v/ast/ast.v +++ b/vlib/v/ast/ast.v @@ -349,7 +349,7 @@ pub mut: end_comments []Comment // comments that after const field // the comptime_expr_value field is filled by the checker, when it has enough // info to evaluate the constant at compile time - comptime_expr_value ComptTimeConstValue = empty_comptime_const_expr() + comptime_expr_value ComptTimeConstValue = empty_comptime_const_expr } // const declaration @@ -1006,9 +1006,9 @@ pub mut: or_block OrExpr ct_left_value_evaled bool - ct_left_value ComptTimeConstValue = empty_comptime_const_expr() + ct_left_value ComptTimeConstValue = empty_comptime_const_expr ct_right_value_evaled bool - ct_right_value ComptTimeConstValue = empty_comptime_const_expr() + ct_right_value ComptTimeConstValue = empty_comptime_const_expr before_op_comments []Comment after_op_comments []Comment diff --git a/vlib/v/ast/comptime_const_values.v b/vlib/v/ast/comptime_const_values.v index 4780b2a217..3b612b25b0 100644 --- a/vlib/v/ast/comptime_const_values.v +++ b/vlib/v/ast/comptime_const_values.v @@ -15,9 +15,7 @@ pub type ComptTimeConstValue = EmptyExpr | u8 | voidptr -pub fn empty_comptime_const_expr() ComptTimeConstValue { - return EmptyExpr(0) -} +pub const empty_comptime_const_expr = ComptTimeConstValue(EmptyExpr(0)) pub fn (val ComptTimeConstValue) i8() ?i8 { x := val.i64()? diff --git a/vlib/v/gen/c/assign.v b/vlib/v/gen/c/assign.v index 80b6845a2a..c9c0506ce7 100644 --- a/vlib/v/gen/c/assign.v +++ b/vlib/v/gen/c/assign.v @@ -493,7 +493,9 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) { concrete_types := (left_sym.info as ast.Struct).concrete_types mut method_name := left_sym.cname + '_' + util.replace_op(extracted_op) method_name = g.generic_fn_name(concrete_types, method_name) - g.write(' = ${method_name}(') + g.write(' = ') + g.write(method_name) + g.write('(') g.expr(left) g.write(', ') g.expr(val) @@ -504,7 +506,9 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) { && !left_sym.has_method(extracted_op) { g.write(' = ') g.expr(left) - g.write(' ${extracted_op} ') + g.write(' ') + g.write(extracted_op) + g.write(' ') g.expr(val) g.write(';') return @@ -631,7 +635,11 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) { g.writeln(';') } } else if !g.is_arraymap_set && !str_add && !op_overloaded { - g.write(' ${op} ') + // ordinary `=` in `x = 2 * y;` + // Note, that this branch *deliberately does not use interpolation* + g.write(' ') + g.write(op.str()) + g.write(' ') } else if str_add || op_overloaded { g.write(', ') } diff --git a/vlib/v/gen/c/infix.v b/vlib/v/gen/c/infix.v index 0d74b77a94..374d94503a 100644 --- a/vlib/v/gen/c/infix.v +++ b/vlib/v/gen/c/infix.v @@ -1016,7 +1016,9 @@ fn (mut g Gen) gen_is_none_check(node ast.InfixExpr) { g.write(' ') g.write('${left_var}.state') } - g.write(' ${node.op.str()} ') + g.write(' ') + g.write(node.op.str()) + g.write(' ') g.write('2') // none state } @@ -1030,7 +1032,9 @@ fn (mut g Gen) gen_plain_infix_expr(node ast.InfixExpr) { g.write('*') } g.expr(node.left) - g.write(' ${node.op.str()} ') + g.write(' ') + g.write(node.op.str()) + g.write(' ') if node.right_type.is_ptr() && node.right.is_auto_deref_var() { g.write('*') g.expr(node.right)