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_) {