mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen/checker: fixes & fixes & tmp fixes :D
This commit is contained in:
@@ -205,7 +205,7 @@ pub const (
|
||||
pub const (
|
||||
builtin_type_names = ['void', 'voidptr', 'charptr', 'byteptr', 'i8', 'i16', 'int', 'i64', 'u16', 'u32', 'u64',
|
||||
'f32', 'f64', 'string', 'char', 'byte', 'bool', 'none', 'array', 'array_fixed', 'map', 'struct',
|
||||
'mapnode', 'ustring']
|
||||
'mapnode', 'ustring', 'size_t']
|
||||
)
|
||||
|
||||
pub struct MultiReturn {
|
||||
@@ -411,6 +411,10 @@ pub fn (t mut Table) register_builtin_type_symbols() {
|
||||
kind: .map
|
||||
name: 'map'
|
||||
})
|
||||
t.register_type_symbol(TypeSymbol{
|
||||
kind: .placeholder
|
||||
name: 'size_t'
|
||||
})
|
||||
// TODO: remove. for v1 map compatibility
|
||||
map_string_string_idx := t.find_or_register_map(string_type, string_type)
|
||||
map_string_int_idx := t.find_or_register_map(string_type, int_type)
|
||||
|
||||
@@ -470,6 +470,15 @@ pub fn (t &Table) check(got, expected Type) bool {
|
||||
&& (got_idx in pointer_type_idxs || got_idx in number_type_idxs) {
|
||||
return true
|
||||
}
|
||||
// see hack in checker IndexExpr line #691
|
||||
if (got_idx == byte_type_idx && exp_idx == byteptr_type_idx) //
|
||||
|| (exp_idx == byte_type_idx && got_idx == byteptr_type_idx) {
|
||||
return true
|
||||
}
|
||||
if (got_idx == char_type_idx && exp_idx == charptr_type_idx) //
|
||||
|| (exp_idx == char_type_idx && got_idx == charptr_type_idx) {
|
||||
return true
|
||||
}
|
||||
// # NOTE: use symbols from this point on for perf
|
||||
got_type_sym := t.get_type_symbol(got)
|
||||
exp_type_sym := t.get_type_symbol(expected)
|
||||
@@ -477,11 +486,6 @@ pub fn (t &Table) check(got, expected Type) bool {
|
||||
if (got_type_sym.is_int() && exp_type_sym.kind == .enum_) || (exp_type_sym.is_int() && got_type_sym.kind == .enum_) {
|
||||
return true
|
||||
}
|
||||
// TODO: actually check for & handle pointers with name_expr
|
||||
// see hack in checker IndexExpr line #691
|
||||
if (got_type_sym.kind == .byte && exp_type_sym.kind == .byteptr) || (exp_type_sym.kind == .byte && got_type_sym.kind == .byteptr) {
|
||||
return true
|
||||
}
|
||||
// TODO
|
||||
// if got_type_sym.kind == .array && exp_type_sym.kind == .array {
|
||||
// return true
|
||||
|
||||
Reference in New Issue
Block a user