Skip to content

Commit b01f482

Browse files
authored
cgen: fix selector call with reserved c name (fix #23170) (#23175)
1 parent 066f825 commit b01f482

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

vlib/v/gen/c/fn.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,7 @@ fn (mut g Gen) fn_call(node ast.CallExpr) {
21802180
// Skip "C."
21812181
name = util.no_dots(name[2..])
21822182
} else {
2183-
name = c_fn_name(name)
2183+
name = if is_selector_call { c_name(name) } else { c_fn_name(name) }
21842184
}
21852185
if g.pref.translated || g.file.is_translated || node.is_file_translated {
21862186
// For `@[c: 'P_TryMove'] fn p_trymove( ... `
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
struct Foo {
2+
}
3+
4+
struct Bar {
5+
do fn () bool = unsafe { nil }
6+
}
7+
8+
fn (f Foo) get() Bar {
9+
return Bar{
10+
do: foobar
11+
}
12+
}
13+
14+
fn foobar() bool {
15+
return true
16+
}
17+
18+
fn test_main() {
19+
t := Foo{}
20+
assert t.get().do() == true
21+
}

0 commit comments

Comments
 (0)