From 8497d637d97a667d8af69daf4ee2cb1e3acbde51 Mon Sep 17 00:00:00 2001 From: Joe Conigliaro Date: Mon, 2 Mar 2020 23:52:41 +1100 Subject: [PATCH] v2: allow pointers to be initialized with 0 --- vlib/v/table/table.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/v/table/table.v b/vlib/v/table/table.v index ee52f79912..003e7bcb5c 100644 --- a/vlib/v/table/table.v +++ b/vlib/v/table/table.v @@ -372,6 +372,8 @@ pub fn (t &Table) check(got, expected Type) bool { exp_type_sym := t.get_type_symbol(expected) got_idx := type_idx(got) exp_idx := type_idx(expected) + // got_is_ptr := type_is_ptr(got) + exp_is_ptr := type_is_ptr(expected) // println('check: $got_type_sym.name, $exp_type_sym.name') if got_type_sym.kind == .none_ { // TODO @@ -386,6 +388,10 @@ pub fn (t &Table) check(got, expected Type) bool { if got_type_sym.is_int() && exp_type_sym.is_int() { return true } + // allow pointers to be initialized with 0. TODO: use none instead + if exp_is_ptr && got_idx == int_type_idx { + return true + } // allow enum value to be used as int if (got_type_sym.is_int() && exp_type_sym.kind == .enum_) || (exp_type_sym.is_int() && got_type_sym.kind == .enum_) {