Skip to content

Commit

Permalink
optmize
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 14, 2025
1 parent 882db20 commit bdfeaee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions vlib/v/ast/ast.v
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ pub mut:
pos token.Pos
should_be_ptr bool // fn expects a ptr for this arg
// tmp_name string // for autofree
ct_expr bool // true, when the expression is a comptime/generic expression
}

// function return statement
Expand Down
6 changes: 6 additions & 0 deletions vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,9 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
if func.params.len == 0 {
continue
}
if !c.inside_recheck {
call_arg.ct_expr = c.comptime.is_comptime(call_arg.expr)
}
if !func.is_variadic && has_decompose {
c.error('cannot have parameter after array decompose', node.pos)
}
Expand Down Expand Up @@ -2383,6 +2386,9 @@ fn (mut c Checker) method_call(mut node ast.CallExpr, mut continue_check &bool)
} else {
method.params[i + 1].typ
}
if !c.inside_recheck {
arg.ct_expr = c.comptime.is_comptime(arg.expr)
}
// If initialize a generic struct with short syntax,
// need to get the parameter information from the original generic method
if is_method_from_embed && arg.expr is ast.StructInit {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/c/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ fn (mut g Gen) keep_alive_call_postgen(node ast.CallExpr, tmp_cnt_save int) {

@[inline]
fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang ast.Language, is_smartcast bool) {
arg_typ := if g.comptime.is_comptime(arg.expr) {
arg_typ := if arg.ct_expr {
g.unwrap_generic(g.type_resolver.get_type(arg.expr))
} else {
g.unwrap_generic(arg.typ)
Expand Down

0 comments on commit bdfeaee

Please sign in to comment.