mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: fix formating cascade generic types call_expr (#10107)
This commit is contained in:
parent
9d8489b025
commit
4d7f15b55b
@ -1651,6 +1651,10 @@ fn (mut f Fmt) write_generic_if_require(node ast.CallExpr) {
|
||||
f.write(', ')
|
||||
}
|
||||
}
|
||||
// avoid `<Foo<int>>` => `<Foo<int> >`
|
||||
if f.out.last_n(1) == '>' {
|
||||
f.write(' ')
|
||||
}
|
||||
f.write('>')
|
||||
}
|
||||
}
|
||||
|
27
vlib/v/fmt/tests/generics_cascade_types_keep.vv
Normal file
27
vlib/v/fmt/tests/generics_cascade_types_keep.vv
Normal file
@ -0,0 +1,27 @@
|
||||
struct Foo<T> {
|
||||
pub:
|
||||
data T
|
||||
}
|
||||
|
||||
struct Foo1 {}
|
||||
|
||||
struct Foo2 {}
|
||||
|
||||
fn multi_generic_args<T, V>(t T, v V) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
fn main() {
|
||||
v1, v2 := -1, 1
|
||||
|
||||
// not generic
|
||||
a1, a2 := v1 < v2, v2 > v1
|
||||
assert a1 && a2
|
||||
b1, b2 := v1 < simplemodule.zero, v2 > v1
|
||||
assert b1 && b2
|
||||
|
||||
// generic
|
||||
assert multi_generic_args<int, string>(0, 's')
|
||||
assert multi_generic_args<Foo1, Foo2>(Foo1{}, Foo2{})
|
||||
assert multi_generic_args<Foo<int>, Foo<int> >(Foo<int>{}, Foo<int>{})
|
||||
}
|
Loading…
Reference in New Issue
Block a user