Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 2, 2025
1 parent e9bec4f commit 07e8dc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion vlib/v/gen/c/assign.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion vlib/v/type_resolver/comptime_resolver.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 07e8dc5

Please sign in to comment.