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

parser: fix parsing interface methods with varargs (#8229)

This commit is contained in:
Enzo
2021-01-20 22:15:02 +01:00
committed by GitHub
parent 94b5e47ba8
commit 55efd8309a
3 changed files with 38 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
interface Element {
method(params ...f64) string
}
struct Foo {}
fn (f &Foo) method(params ...f64) string {
return params.str()
}
fn test_variadic_array_decompose() {
mut a := []Element{}
a << Foo{}
input := [0.0, 1.0]
assert a[0].method(...input) == '[0, 1]'
assert a[0].method(...[0.0, 1.0]) == '[0, 1]'
}
fn test_variadic_multiple_args() {
mut a := []Element{}
a << Foo{}
assert a[0].method(0.0, 1.0) == '[0, 1]'
}