fmt: fix multiple problems with types (#6603)
parent
230e9868d1
commit
93bb7564dc
|
@ -0,0 +1,3 @@
|
|||
pub fn (a []int) reduce(iter fn (int, int) int, accum_start int) int {
|
||||
iter(accum_start)
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fn foo() [1]f32 {
|
||||
return [f32(0.0)]!!
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import v.ast
|
||||
|
||||
// TODO fix `fn foo(my_map map[string]map[string]int) []ast.FnDecl {`
|
||||
fn foo(my_map map[string]map[string]int) int {
|
||||
return 0
|
||||
}
|
|
@ -801,7 +801,9 @@ pub:
|
|||
pub fn (table &Table) type_to_str(t Type) string {
|
||||
sym := table.get_type_symbol(t)
|
||||
mut res := sym.name
|
||||
if sym.kind == .multi_return {
|
||||
if sym.kind in [.array_fixed, .function] {
|
||||
res = sym.source_name
|
||||
} else if sym.kind == .multi_return {
|
||||
res = '('
|
||||
if t.has_flag(.optional) {
|
||||
res = '?' + res
|
||||
|
|
|
@ -361,17 +361,20 @@ pub fn no_dots(s string) string {
|
|||
return s.replace('.', '__')
|
||||
}
|
||||
|
||||
const (
|
||||
map_prefix = 'map[string]'
|
||||
)
|
||||
|
||||
// no_cur_mod - removes cur_mod. prefix from typename,
|
||||
// but *only* when it is at the start, i.e.:
|
||||
// no_cur_mod('vproto.Abdcdef', 'proto') == 'vproto.Abdcdef'
|
||||
// even though proto. is a substring
|
||||
pub fn no_cur_mod(typename, cur_mod string) string {
|
||||
mut res := typename
|
||||
map_prefix := 'map[string]'
|
||||
mod_prefix := cur_mod + '.'
|
||||
has_map_prefix := res.starts_with(map_prefix)
|
||||
if has_map_prefix {
|
||||
res = res.replace(map_prefix, '')
|
||||
res = res.replace_once(map_prefix, '')
|
||||
}
|
||||
no_symbols := res.trim_left('&[]')
|
||||
should_shorten := no_symbols.starts_with(mod_prefix)
|
||||
|
|
Loading…
Reference in New Issue