Skip to content

Conversation

@thevilledev
Copy link
Contributor

When checking arguments for variadic methods, the index passed to InElem used "fnNumIn-1", but fnNumIn had already been decremented to exclude the receiver. This caused InElem to access the receiver type (index 0) instead of the variadic parameter type, causing a type error ("cannot use string as argument").

Add "fnInOffset" to the index calculation to correctly reference the variadic parameter. Regression tests included.

Fixes #888.

When checking arguments for variadic methods, the index passed to
InElem used "fnNumIn-1", but fnNumIn had already been decremented
to exclude the receiver. This caused InElem to access the receiver
type (index 0) instead of the variadic parameter type, causing a
type error ("cannot use string as argument").

Add "fnInOffset" to the index calculation to correctly reference the
variadic parameter. Regression tests included.

Signed-off-by: Ville Vesilehto <[email protected]>
@antonmedv antonmedv merged commit c020e95 into expr-lang:master Dec 25, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

struct methods with variadic parameter fail to compile

2 participants