ast,checker: fix `v test-self` by relaxing the is_number checks

pull/9610/head
Delyan Angelov 2021-04-05 18:45:03 +03:00
parent ab77453f5f
commit abbb08b28c
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 10 additions and 4 deletions

View File

@ -278,12 +278,12 @@ pub fn (typ Type) is_pointer() bool {
[inline]
pub fn (typ Type) is_float() bool {
return typ.idx() in ast.float_type_idxs
return typ.clear_flags() in ast.float_type_idxs
}
[inline]
pub fn (typ Type) is_int() bool {
return int(typ) in ast.integer_type_idxs
return typ.clear_flags() in ast.integer_type_idxs
}
[inline]
@ -303,7 +303,13 @@ pub fn (typ Type) is_int_literal() bool {
[inline]
pub fn (typ Type) is_number() bool {
return int(typ) in ast.number_type_idxs
return typ.clear_flags() in ast.number_type_idxs
}
pub fn (typ Type) is_number_or_literal() bool {
res := int(typ) in ast.number_type_idxs
eprintln('> is_number_or_literal typ: $typ.debug() | res: $res')
return res
}
[inline]

View File

@ -203,7 +203,7 @@ fn (mut c Checker) check_shift(left_type ast.Type, right_type ast.Type, left_pos
return left_type
}
pub fn (c &Checker) promote(left_type ast.Type, right_type ast.Type) ast.Type {
pub fn (mut c Checker) promote(left_type ast.Type, right_type ast.Type) ast.Type {
if left_type.is_ptr() || left_type.is_pointer() {
if right_type.is_int() {
return left_type