1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: check option fn returning error (fix #17423) (#17438)

This commit is contained in:
yuyi
2023-03-02 21:49:50 +08:00
committed by GitHub
parent 8f7c35552d
commit 17000ef7b6
49 changed files with 129 additions and 106 deletions

View File

@ -53,7 +53,7 @@ fn (ver RawVersion) is_missing(typ int) bool {
return typ >= ver.raw_ints.len - 1
}
fn (raw_ver RawVersion) coerce() ?Version {
fn (raw_ver RawVersion) coerce() !Version {
ver := raw_ver.complete()
if !is_valid_number(ver.raw_ints[semver.ver_major]) {
return error('Invalid major version: ${ver.raw_ints}[ver_major]')

View File

@ -69,7 +69,7 @@ fn (c Comparator) satisfies(ver Version) bool {
return false
}
fn parse_range(input string) ?Range {
fn parse_range(input string) !Range {
raw_comparator_sets := input.split(semver.comparator_set_sep)
mut comparator_sets := []ComparatorSet{}
for raw_comp_set in raw_comparator_sets {
@ -84,7 +84,7 @@ fn parse_range(input string) ?Range {
return Range{comparator_sets}
}
fn parse_comparator_set(input string) ?ComparatorSet {
fn parse_comparator_set(input string) !ComparatorSet {
raw_comparators := input.split(semver.comparator_sep)
if raw_comparators.len > 2 {
return &InvalidComparatorFormatError{

View File

@ -38,7 +38,7 @@ pub fn (err InvalidVersionFormatError) msg() string {
// * Constructor.
// from returns a `Version` structure parsed from `input` `string`.
pub fn from(input string) ?Version {
pub fn from(input string) !Version {
if input.len == 0 {
return &EmptyInputError{}
}
@ -114,7 +114,7 @@ import semver
v := semver.coerce('1.3-RC1-b2') or { semver.Version{} }
assert v.satisfies('>1.0 <2.0') == true // 1.3.0
*/
pub fn coerce(input string) ?Version {
pub fn coerce(input string) !Version {
return coerce_version(input)
}

View File

@ -8,7 +8,7 @@ fn is_version_valid(input string) bool {
}
[inline]
fn coerce_version(input string) ?Version {
fn coerce_version(input string) !Version {
raw_ver := parse(input)
ver := raw_ver.coerce() or { return error('Invalid version for input "${input}"') }
return ver