diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 4cdb421acb..50d80081c9 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -2997,6 +2997,7 @@ fn (mut p Parser) type_decl() ast.TypeDecl { // function type: `type mycallback = fn(string, int)` fn_name := p.prepend_mod(name) fn_type := p.parse_fn_type(fn_name) + p.table.get_type_symbol(fn_type).is_public = is_pub type_pos = type_pos.extend(p.tok.position()) comments = p.eat_comments(same_line: true) return ast.FnTypeDecl{ diff --git a/vlib/v/tests/imported_symbols_test.v b/vlib/v/tests/imported_symbols_test.v index 3ffb09b244..8281d5bbc0 100644 --- a/vlib/v/tests/imported_symbols_test.v +++ b/vlib/v/tests/imported_symbols_test.v @@ -1,6 +1,10 @@ module main -import geometry { Line, Point, Shape, module_name, point_str } +import geometry { Line, Point, PointCond, Shape, module_name, point_str } + +fn point_is(p Point, cond PointCond) bool { + return cond(p) +} fn test_imported_symbols_types() { // struct init @@ -17,6 +21,11 @@ fn test_imported_symbols_types() { ps: [p0, p1] } assert l0.ps[0].y == 20 + + cond := fn (p Point) bool { + return p.x == 10 + } + assert point_is(p0, cond) } fn test_imported_symbols_functions() { diff --git a/vlib/v/tests/modules/geometry/geometry.v b/vlib/v/tests/modules/geometry/geometry.v index 8995dc4ebd..0f7f522570 100644 --- a/vlib/v/tests/modules/geometry/geometry.v +++ b/vlib/v/tests/modules/geometry/geometry.v @@ -35,3 +35,5 @@ pub fn (a Point) str() string { pub fn point_str(a Point) string { return a.str() } + +pub type PointCond = fn (p Point) bool