You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you create a non-static lambda function that captures more than two variables, the decompiler creates seemingly invalid syntax that probably wouldn't compile as C# and the transformed VHDL doesn't compile in v++. This may be an ICSharpCode.Decompiler bug, we can investigate this possibility after we've upgraded to the latest version (see #84).
See an example of the problem here. Originally I tried tasks[index] = Task.Factory.StartNew(index => ((int)index + step) * heightFactor, index);
but then the decompiled & processed syntax tree would generate display classes with only one field each:
Note that this.CS$<>8__locals1.heightFactor; is invalid according to VS Code, Rider and GitHub syntax highlighting. This is the build output log showing the errors according to v++. Besides that, it's also unnecessarily complex to have two nested display classes instead of just one for such a simple mathematical expression. Manually creating the class that contains all values so nothing is captured by the lambda (as I did here) is a valid workaround. In this case the lambda is effectively static so it results in no compiler generated classes.
github-actionsbot
changed the title
Problems with lambdas that capture multiple variables
Problems with lambdas that capture multiple variables (HAST-286)
Nov 15, 2022
When you create a non-static lambda function that captures more than two variables, the decompiler creates seemingly invalid syntax that probably wouldn't compile as C# and the transformed VHDL doesn't compile in v++. This may be an ICSharpCode.Decompiler bug, we can investigate this possibility after we've upgraded to the latest version (see #84).
See an example of the problem here. Originally I tried
tasks[index] = Task.Factory.StartNew(index => ((int)index + step) * heightFactor, index);
but then the decompiled & processed syntax tree would generate display classes with only one field each:
Note that
this.CS$<>8__locals1.heightFactor;
is invalid according to VS Code, Rider and GitHub syntax highlighting. This is the build output log showing the errors according to v++. Besides that, it's also unnecessarily complex to have two nested display classes instead of just one for such a simple mathematical expression. Manually creating the class that contains all values so nothing is captured by the lambda (as I did here) is a valid workaround. In this case the lambda is effectively static so it results in no compiler generated classes.Jira issue
The text was updated successfully, but these errors were encountered: