Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Oct 15, 2024
1 parent 95ae170 commit 1e326d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions vlib/v/ast/scope.v
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ pub fn (s &Scope) has_inherited_vars() bool {
return false
}

pub fn (s &Scope) is_inherited_var(var_name string) bool {
for _, obj in s.objects {
if obj is Var {
if obj.is_inherited && obj.name == var_name {
return true
}
}
}
return false
}

pub fn (sc &Scope) show(depth int, max_depth int) string {
mut out := ''
mut indent := ''
Expand Down
3 changes: 2 additions & 1 deletion vlib/v/gen/c/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ fn (mut g Gen) c_fn_name(node &ast.FnDecl) string {
name = name.replace_each(c_fn_name_escape_seq)
}
}
if node.is_anon && g.comptime.comptime_for_method_var != '' {
if node.is_anon && g.comptime.comptime_for_method_var != ''
&& node.scope.is_inherited_var('method') {
name = '${name}_${g.comptime.comptime_loop_id}'
}
if node.language == .c {
Expand Down

0 comments on commit 1e326d0

Please sign in to comment.