From 07e8dc5385ad9364581eb869f167877ebb911488 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Thu, 2 Jan 2025 17:55:01 -0300 Subject: [PATCH] fix --- vlib/v/gen/c/assign.v | 3 ++- vlib/v/type_resolver/comptime_resolver.v | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/c/assign.v b/vlib/v/gen/c/assign.v index 9d1413ab7bb805..609dadb5e71e49 100644 --- a/vlib/v/gen/c/assign.v +++ b/vlib/v/gen/c/assign.v @@ -371,7 +371,8 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) { left.obj.typ = var_type g.assign_ct_type = var_type } - } else if val is ast.InfixExpr && g.comptime.is_comptime(val.left) { + } else if val is ast.InfixExpr && val.op in [.plus, .minus, .mul, .div, .mod] + && g.comptime.is_comptime(val.left) { ctyp := g.unwrap_generic(g.type_resolver.get_type(val.left)) if ctyp != ast.void_type { ct_type_var := g.comptime.get_ct_type_var(val.left) diff --git a/vlib/v/type_resolver/comptime_resolver.v b/vlib/v/type_resolver/comptime_resolver.v index a01813dc08d307..c7cf6b0236df60 100644 --- a/vlib/v/type_resolver/comptime_resolver.v +++ b/vlib/v/type_resolver/comptime_resolver.v @@ -50,7 +50,11 @@ pub fn (t &ResolverInfo) is_comptime(node ast.Expr) bool { return node.expr is ast.Ident && node.expr.ct_expr } ast.InfixExpr { - return t.is_comptime(node.left) || t.is_comptime(node.right) + if node.op in [.plus, .minus, .mul, .div, .mod] { + t.is_comptime(node.left) || t.is_comptime(node.right) + } else { + false + } } ast.ParExpr { return t.is_comptime(node.expr)