mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: minor cleanup of optional and result (#16382)
This commit is contained in:
parent
26d643fc5d
commit
196b01aef7
@ -282,6 +282,9 @@ pub fn (t Type) debug() []string {
|
|||||||
if t.has_flag(.optional) {
|
if t.has_flag(.optional) {
|
||||||
res << 'optional'
|
res << 'optional'
|
||||||
}
|
}
|
||||||
|
if t.has_flag(.result) {
|
||||||
|
res << 'result'
|
||||||
|
}
|
||||||
if t.has_flag(.variadic) {
|
if t.has_flag(.variadic) {
|
||||||
res << 'variadic'
|
res << 'variadic'
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ pub fn (mut c Checker) get_default_fmt(ftyp ast.Type, typ ast.Type) u8 {
|
|||||||
}
|
}
|
||||||
if ftyp in [ast.string_type, ast.bool_type]
|
if ftyp in [ast.string_type, ast.bool_type]
|
||||||
|| sym.kind in [.enum_, .array, .array_fixed, .struct_, .map, .multi_return, .sum_type, .interface_, .none_]
|
|| sym.kind in [.enum_, .array, .array_fixed, .struct_, .map, .multi_return, .sum_type, .interface_, .none_]
|
||||||
|| ftyp.has_flag(.optional) || sym.has_method('str') {
|
|| ftyp.has_flag(.optional) || ftyp.has_flag(.result) || sym.has_method('str') {
|
||||||
return `s`
|
return `s`
|
||||||
} else {
|
} else {
|
||||||
return `_`
|
return `_`
|
||||||
|
@ -67,6 +67,9 @@ fn (mut g Gen) get_str_fn(typ ast.Type) string {
|
|||||||
if typ.has_flag(.optional) {
|
if typ.has_flag(.optional) {
|
||||||
unwrapped.set_flag(.optional)
|
unwrapped.set_flag(.optional)
|
||||||
}
|
}
|
||||||
|
if typ.has_flag(.result) {
|
||||||
|
unwrapped.set_flag(.result)
|
||||||
|
}
|
||||||
styp := g.typ(unwrapped)
|
styp := g.typ(unwrapped)
|
||||||
mut sym := g.table.sym(unwrapped)
|
mut sym := g.table.sym(unwrapped)
|
||||||
mut str_fn_name := styp_to_str_fn_name(styp)
|
mut str_fn_name := styp_to_str_fn_name(styp)
|
||||||
|
Loading…
Reference in New Issue
Block a user