Open fmoo opened 2 years ago
Also repros on vscode extension v2.2.40
This issue has been a weird one for a while and have made some progress. This comment is more for my own records while this issue is still being worked on.
This isn't being caused by nesting, but is something to do with the registered type inference, but weirder still only when using the AddFunction
call on the dialogue runner.
So the following yarn:
<<declare $_spam = "">>
<<set $_spam = reverse("value")>>
does not work if you declare the function via the following code:
runner.AddFunction<string, string>("reverse", (s) => new string(s.Reverse().ToArray()));
but will work fine if you do it like this:
[YarnFunction("reverse")]
public static string Reverse(string value)
{
return new string(value.Reverse().ToArray());
}
This occurs both on mainline YS/VSCode but also on the WIP 3.0 branch with the improved type system there.
What is the current behavior?
When nesting functions, the compiler cannot correctly infer the type of the inner function in order to invoke the outer one.
A yarn error is shown in Unity. The error is also shown in the vscode extension
Please provide the steps to reproduce, and if possible a minimal demo of the problem:
Given the following custom functions:
Called as such:
The following error is raised in Unity:
The following error is raised in vscode:
What is the expected behavior?
There should be no errors shown in unity or vscode for this scenario.
Please tell us about your environment:
Other information