diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index 1d5fc20ae9ceb3..37a9a014a18f34 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -2180,7 +2180,7 @@ fn (mut g Gen) fn_call(node ast.CallExpr) { // Skip "C." name = util.no_dots(name[2..]) } else { - name = c_fn_name(name) + name = if is_selector_call { c_name(name) } else { c_fn_name(name) } } if g.pref.translated || g.file.is_translated || node.is_file_translated { // For `@[c: 'P_TryMove'] fn p_trymove( ... ` diff --git a/vlib/v/tests/selector_call_with_reserved_c_name_test.v b/vlib/v/tests/selector_call_with_reserved_c_name_test.v new file mode 100644 index 00000000000000..5dc13ae9610944 --- /dev/null +++ b/vlib/v/tests/selector_call_with_reserved_c_name_test.v @@ -0,0 +1,21 @@ +struct Foo { +} + +struct Bar { + do fn () bool = unsafe { nil } +} + +fn (f Foo) get() Bar { + return Bar{ + do: foobar + } +} + +fn foobar() bool { + return true +} + +fn test_main() { + t := Foo{} + assert t.get().do() == true +}