Closures supported?

Hi, I’m looking into a crash around this function in ECS Netcode: com.unity.netcode/Runtime/Snapshot/GhostComponentSerializerCollectionSystemGroup.cs at d3ac47052d05be459ef9273e10ea0e353c3be98a · needle-mirror/com.unity.netcode · GitHub

The one thing that stood out is that availableVariants is used via closure in AddAndCount and I’m just wondering if this really is supported in Burst? I’ve seen somewhere else that that wasn’t the case, but not sure what the current status is there or if local functions is some special case.

C# compiler trickery. It works by way of the closure being compiled down to a struct, and the local function being compiled to receive a ref to an instance of it. Burst can handle these, obviously.
Example:

1 Like