checker: use .clear_flags() when comparing number literals

pull/9608/head
Delyan Angelov 2021-04-05 10:39:48 +03:00
parent 9fcdf33501
commit 7a9607b028
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 3 additions and 3 deletions

View File

@ -140,12 +140,12 @@ pub fn (mut c Checker) check_basic(got ast.Type, expected ast.Type) bool {
return true return true
} }
// allow `return 0` in a function with `?int` return type // allow `return 0` in a function with `?int` return type
expected_nonopt := expected.clear_flag(.optional) expected_nonflagged := expected.clear_flags()
if got == ast.int_literal_type && expected_nonopt.is_int() { if got == ast.int_literal_type && expected_nonflagged.is_int() {
return true return true
} }
// allow `return 0` in a function with `?f32` return type // allow `return 0` in a function with `?f32` return type
if got == ast.float_literal_type && expected_nonopt.is_float() { if got == ast.float_literal_type && expected_nonflagged.is_float() {
return true return true
} }
return false return false