mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: use .clear_flags() when comparing number literals
This commit is contained in:
parent
9fcdf33501
commit
7a9607b028
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user