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

vfmt: fix x := Repo<User,Permission>{}

This commit is contained in:
Delyan Angelov 2020-11-11 21:40:56 +02:00
parent 43ce098043
commit 8197463b08
2 changed files with 26 additions and 0 deletions

View File

@ -1272,6 +1272,15 @@ pub fn (mut f Fmt) short_module(name string) string {
if !name.contains('.') {
return name
}
if name.ends_with('>') {
x := name.trim_suffix('>').split('<')
if x.len == 2 {
main := f.short_module(x[0])
genlist := x[1].split(',').map(f.short_module(it)).join(',')
res := '$main<${genlist}>'
return res
}
}
vals := name.split('.')
if vals.len < 2 {
return name

View File

@ -16,6 +16,16 @@ pub mut:
permission U
}
struct User {
mut:
name string
}
struct Permission {
pub mut:
name string
}
fn main() {
foo_int := Foo<int>{2}
assert foo_int.value() == '2'
@ -25,4 +35,11 @@ fn main() {
println(x.db)
println(x.model)
println(x.permission)
//
mut a := Repo<User,Permission>{
model: User{
name: 'joe'
}
}
println(a.model.name)
}