From 9c96b13f9b75e5c6c81a41e9bd65af4b1088cb17 Mon Sep 17 00:00:00 2001 From: yuyi Date: Fri, 12 Aug 2022 22:24:23 +0800 Subject: [PATCH] ast: fix anon fn with nested anon fn argument (#15415) --- vlib/v/ast/table.v | 2 +- vlib/v/tests/anon_fn_with_nested_anon_fn_args_test.v | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/anon_fn_with_nested_anon_fn_args_test.v diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 74b018fdc7..46280b7126 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -219,7 +219,7 @@ pub fn (t &Table) fn_type_signature(f &Fn) string { } else { sig += arg_type_sym.str().to_lower().replace_each(['.', '__', '&', '', '[', 'arr_', 'chan ', 'chan_', 'map[', 'map_of_', ']', '_to_', '<', '_T_', ',', '_', ' ', '', - '>', '']) + '>', '', '(', '_', ')', '_']) } if i < f.params.len - 1 { sig += '_' diff --git a/vlib/v/tests/anon_fn_with_nested_anon_fn_args_test.v b/vlib/v/tests/anon_fn_with_nested_anon_fn_args_test.v new file mode 100644 index 0000000000..0e36c68b54 --- /dev/null +++ b/vlib/v/tests/anon_fn_with_nested_anon_fn_args_test.v @@ -0,0 +1,12 @@ +module main + +fn test_anon_fn_with_nested_anon_fn_args() { + mut xa := fn (x fn (int) string, y int) string { + return x(y) + } + a := xa(fn (i int) string { + return 'a' + i.str() + }, 8) + println(a) + assert a == 'a8' +}