I'm getting errors with the following IL. Any idea why? It looks fine to me!
The issue is with the lines stloc.4/ldloc.4 that are highlighted in bold.
The syntax highlighting is from Rider, but I get the same issue with ilasm as well.
I'm running this on MacOS.

Problem is that there's no
stloc.4,stloc.xgoes up to 3. You should usestlocfollowed by number, e.g.stloc 4. Since index of variable is less than 255, it's possible to usestloc.s 4to save few bytes in resulting assembly. Same applies toldloc.4at next line