From 7cf058feac57fa9eefc693482157decf24838343 Mon Sep 17 00:00:00 2001 From: BigBlack <840206@qq.com> Date: Thu, 5 Sep 2019 17:09:41 +0800 Subject: [PATCH] parser: function pointers --- compiler/parser.v | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/parser.v b/compiler/parser.v index abc2b58780..c51b673784 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1646,9 +1646,16 @@ fn (p mut Parser) name_expr() string { // TODO verify this and handle errors peek := p.peek() if peek != .lpar && peek != .lt { + // Register anon fn type + fn_typ := Type { + name: f.typ_str()// 'fn (int, int) string' + mod: p.mod + func: f + } + p.table.register_type2(fn_typ) p.gen(p.table.cgen_name(f)) p.next() - return 'void*' + return f.typ_str() //'void*' } // TODO bring back if f.typ == 'void' && !p.inside_if_expr {