0 issues 1 contributor 4 branches 0 releases
Additions: 14 Deletions: 2 View patch
1 ''
2 }
3
4- g.write('$ret_styp ($msvc_call_conv*${g.get_ternary_name(ident.name)}) (')
5+ fn_name := c_name(g.get_ternary_name(ident.name))
6+ g.write('$ret_styp ($msvc_call_conv*$fn_name) (')
7 def_pos := g.definitions.len
8 g.fn_decl_params(func.func.params, unsafe { nil }, false)
9 g.definitions.go_back(g.definitions.len - def_pos)
10
1 // generate function variable definition, e.g. `void (*var_name) (int, string)`
2 fn (mut g Gen) fn_var_signature(return_type ast.Type, arg_types []ast.Type, var_name string) string {
3 ret_styp := g.typ(return_type)
4- mut sig := '$ret_styp (*$var_name) ('
5+ mut sig := '$ret_styp (*${c_name(var_name)}) ('
6 for j, arg_typ in arg_types {
7 arg_sym := g.table.sym(arg_typ)
8 if arg_sym.info is ast.FnType {
9
1new file mode 100644
2+fn ret_int() fn (int) int {
3+ return fn (i int) int {
4+ return i
5+ }
6+}
7+
8+fn test_fn_var_name_using_reserved() {
9+ new := ret_int()
10+ println(new(42))
11+ assert new(42) == 42
12+}
13