VSCodeExtension icon indicating copy to clipboard operation
VSCodeExtension copied to clipboard

False negative error `Function X expects 0 parameters, but received 1` when using Unity's `runner.AddFunction<...>`

Open fmoo opened this issue 1 year ago • 0 comments

What is the current behavior?

When defining custom functions in Unity, that take an instance method or lambda, the vscode extension seems to parse these as having 0 expected arguments instead of what is in the typehint(s).

Please provide the steps to reproduce, and if possible a minimal demo of the problem:

Register a 1-argument custom function using the following:

runner.AddFunction<string, string>("test1", s => s);

or a more roundabout:

var scopedCommands = new RunnerScoped(runner);
runner.AddFunction<string, string>("test1", scopedCommands.Test1);

Then in yarn:

<<if test1("foo") == "foo">>
  // something
<<endif>>

Observe the error in the Problem panel:

Function test1 expects 0 parameters, but received 1

The behavior previously worked in vscode extension version 2.2.114 and produces the error in 2.2.115 through 2.4.4

What is the expected behavior?

No error is observed in the Problems panel

Please tell us about your environment:

  • Yarn Spinner Version: 2.3
  • Extension Version: 2.4.4
  • Unity Version: 2021.3.25f1

Other information

fmoo avatar Feb 19 '24 10:02 fmoo