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:
25
vlib/v/tests/interface_variadic_test.v
Normal file
25
vlib/v/tests/interface_variadic_test.v
Normal 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]'
|
||||
}
|
Reference in New Issue
Block a user