checker: handle different pointer levels
parent
9593ad20f9
commit
15ba53be21
|
@ -28,8 +28,6 @@ pub fn (mut c Checker) check_basic(got table.Type, expected table.Type) bool {
|
||||||
t := c.table
|
t := c.table
|
||||||
got_idx := t.unalias_num_type(got).idx()
|
got_idx := t.unalias_num_type(got).idx()
|
||||||
exp_idx := t.unalias_num_type(expected).idx()
|
exp_idx := t.unalias_num_type(expected).idx()
|
||||||
// got_is_ptr := got.is_ptr()
|
|
||||||
exp_is_ptr := expected.is_ptr()
|
|
||||||
// exp_is_optional := expected.has_flag(.optional)
|
// exp_is_optional := expected.has_flag(.optional)
|
||||||
// got_is_optional := got.has_flag(.optional)
|
// got_is_optional := got.has_flag(.optional)
|
||||||
// if (exp_is_optional && !got_is_optional) || (!exp_is_optional && got_is_optional) {
|
// if (exp_is_optional && !got_is_optional) || (!exp_is_optional && got_is_optional) {
|
||||||
|
@ -37,6 +35,7 @@ pub fn (mut c Checker) check_basic(got table.Type, expected table.Type) bool {
|
||||||
//}
|
//}
|
||||||
// println('check: $got_type_sym.name, $exp_type_sym.name')
|
// println('check: $got_type_sym.name, $exp_type_sym.name')
|
||||||
// # NOTE: use idxs here, and symbols below for perf
|
// # NOTE: use idxs here, and symbols below for perf
|
||||||
|
// got_is_ptr := got.is_ptr()
|
||||||
if got_idx == exp_idx {
|
if got_idx == exp_idx {
|
||||||
// this is returning true even if one type is a ptr
|
// this is returning true even if one type is a ptr
|
||||||
// and the other is not, is this correct behaviour?
|
// and the other is not, is this correct behaviour?
|
||||||
|
@ -45,6 +44,7 @@ pub fn (mut c Checker) check_basic(got table.Type, expected table.Type) bool {
|
||||||
if got_idx == table.none_type_idx && expected.has_flag(.optional) {
|
if got_idx == table.none_type_idx && expected.has_flag(.optional) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
exp_is_ptr := expected.is_ptr()
|
||||||
// allow pointers to be initialized with 0. TODO: use none instead
|
// allow pointers to be initialized with 0. TODO: use none instead
|
||||||
if exp_is_ptr && got_idx == table.int_type_idx {
|
if exp_is_ptr && got_idx == table.int_type_idx {
|
||||||
return true
|
return true
|
||||||
|
@ -261,6 +261,13 @@ pub fn (mut c Checker) check_types(got table.Type, expected table.Type) bool {
|
||||||
if got == expected {
|
if got == expected {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
got_is_ptr := got.is_ptr()
|
||||||
|
exp_is_ptr := expected.is_ptr()
|
||||||
|
if got_is_ptr && exp_is_ptr {
|
||||||
|
if got.nr_muls() != expected.nr_muls() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
exp_idx := expected.idx()
|
exp_idx := expected.idx()
|
||||||
got_idx := got.idx()
|
got_idx := got.idx()
|
||||||
if exp_idx == got_idx {
|
if exp_idx == got_idx {
|
||||||
|
|
Loading…
Reference in New Issue