Skip to content

Commit 196b01a

Browse files
authored
all: minor cleanup of optional and result (#16382)
1 parent 26d643f commit 196b01a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

vlib/v/ast/types.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ pub fn (t Type) debug() []string {
282282
if t.has_flag(.optional) {
283283
res << 'optional'
284284
}
285+
if t.has_flag(.result) {
286+
res << 'result'
287+
}
285288
if t.has_flag(.variadic) {
286289
res << 'variadic'
287290
}

vlib/v/checker/str.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn (mut c Checker) get_default_fmt(ftyp ast.Type, typ ast.Type) u8 {
3232
}
3333
if ftyp in [ast.string_type, ast.bool_type]
3434
|| sym.kind in [.enum_, .array, .array_fixed, .struct_, .map, .multi_return, .sum_type, .interface_, .none_]
35-
|| ftyp.has_flag(.optional) || sym.has_method('str') {
35+
|| ftyp.has_flag(.optional) || ftyp.has_flag(.result) || sym.has_method('str') {
3636
return `s`
3737
} else {
3838
return `_`

vlib/v/gen/c/auto_str_methods.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ fn (mut g Gen) get_str_fn(typ ast.Type) string {
6767
if typ.has_flag(.optional) {
6868
unwrapped.set_flag(.optional)
6969
}
70+
if typ.has_flag(.result) {
71+
unwrapped.set_flag(.result)
72+
}
7073
styp := g.typ(unwrapped)
7174
mut sym := g.table.sym(unwrapped)
7275
mut str_fn_name := styp_to_str_fn_name(styp)

0 commit comments

Comments
 (0)