diff --git a/vlib/v/ast/types.v b/vlib/v/ast/types.v index b97656ac42..0cae9edaba 100644 --- a/vlib/v/ast/types.v +++ b/vlib/v/ast/types.v @@ -282,6 +282,9 @@ pub fn (t Type) debug() []string { if t.has_flag(.optional) { res << 'optional' } + if t.has_flag(.result) { + res << 'result' + } if t.has_flag(.variadic) { res << 'variadic' } diff --git a/vlib/v/checker/str.v b/vlib/v/checker/str.v index 0811585544..e51f45e103 100644 --- a/vlib/v/checker/str.v +++ b/vlib/v/checker/str.v @@ -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] || 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` } else { return `_` diff --git a/vlib/v/gen/c/auto_str_methods.v b/vlib/v/gen/c/auto_str_methods.v index a522ee26c6..cf9bd88418 100644 --- a/vlib/v/gen/c/auto_str_methods.v +++ b/vlib/v/gen/c/auto_str_methods.v @@ -67,6 +67,9 @@ fn (mut g Gen) get_str_fn(typ ast.Type) string { if typ.has_flag(.optional) { unwrapped.set_flag(.optional) } + if typ.has_flag(.result) { + unwrapped.set_flag(.result) + } styp := g.typ(unwrapped) mut sym := g.table.sym(unwrapped) mut str_fn_name := styp_to_str_fn_name(styp)