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

ast: fix formatting fn variadic of reference param (#11130)

This commit is contained in:
yuyi
2021-08-11 02:14:37 +08:00
committed by GitHub
parent 2ae77c1998
commit aceaaa681d
3 changed files with 28 additions and 2 deletions

View File

@@ -1064,7 +1064,7 @@ pub fn (t &Table) type_to_str_using_aliases(typ Type, import_aliases map[string]
nr_muls--
res = 'shared ' + res
}
if nr_muls > 0 {
if nr_muls > 0 && !typ.has_flag(.variadic) {
res = strings.repeat(`&`, nr_muls) + res
}
if typ.has_flag(.optional) {

View File

@@ -0,0 +1,27 @@
[heap]
struct Foo {
name string
}
fn agg_stuff(stuffs ...&Foo) []&Foo {
stuffs2 := stuffs.clone()
return stuffs2
}
fn arr_stuff(stuffs []&Foo) []&Foo {
stuffs2 := stuffs.clone()
return stuffs2
}
fn main() {
foo1 := &Foo{'foo'}
foo2 := &Foo{'bar'}
foo11 := agg_stuff(foo1, foo2)
println(foo11)
foo22 := arr_stuff([foo1, foo2])
println(foo22)
assert '$foo11' == '$foo22'
}