From 0b235cc893de927bbf92687694b32421f9b8c3ff Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Jan 2020 13:15:04 +0100 Subject: [PATCH] temporary nil fn check --- vlib/compiler/gen_c.v | 3 +++ vlib/compiler/table.v | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index dc49332f76..db1a5ebef9 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -628,6 +628,9 @@ fn type_default(typ string) string { if typ.contains('__') { return '{0}' } + if typ.ends_with('Fn') { // TODO + return '0' + } // Default values for other types are not needed because of mandatory initialization match typ { 'bool' { diff --git a/vlib/compiler/table.v b/vlib/compiler/table.v index ed71a3658f..1224a7039b 100644 --- a/vlib/compiler/table.v +++ b/vlib/compiler/table.v @@ -621,6 +621,10 @@ fn (p mut Parser) check_types2(got_, expected_ string, throw bool) bool { if got.starts_with('varg_') { got = got[5..] } + // fn == 0 temporary + if got == 'int' && expected.ends_with('Fn') { + return true + } // Allow ints to be used as floats if got == 'int' && expected == 'f32' { return true