Invalid subscript in Shader

I’m getting this error:

Which is very weird, because I was using this same shader and was getting no errors until I introduced the StructuredBuffer. As far as I can see, the ‘positionInWorldSpace’ variable is well defined in v2f:

Shader "dichtermut/FogOfWar/Fog"
{
    Properties
    {
        _DistanceThreshold("Distance Threshold", float) = 10.0
    }
    SubShader
    {
        Tags {"RenderType"="Transparent" "Queue"="Transparent"}
        Blend SrcAlpha OneMinusSrcAlpha

        Pass
        {
            HLSLPROGRAM

            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
                float4 positionInWorldSpace : TEXCOORD0;
            };

            StructuredBuffer<float> _CellBuffer;
            int _CellCount;
            float _DistanceThreshold;

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.positionInWorldSpace = mul(unity_ObjectToWorld, v.vertex);
                return o;
            }


            fixed4 frag(v2f i) : SV_Target
            {
                for (int i = 0; i < _CellCount; i++) {
                    float cellPosX = _CellBuffer[2 * i];
                    float cellPosZ = _CellBuffer[2 * i + 1];

                    float distX = length(cellPosX - i.positionInWorldSpace.x);
                    float distZ = length(cellPosZ - i.positionInWorldSpace.z);
                    float dist = distX * distX + distZ * distZ;

                    fixed4 color = fixed4(1,1,1,1);
                    if (dist < _DistanceThreshold * _DistanceThreshold)
                    {
                        color = (1,1,1,0.1);
                        break;
                    }
                }
                return color;
            }

            ENDHLSL
        }
    }
}

Up until now I was only using StructuredBuffer in Compute Shaders, so I’m not sure if they can be used in shaders as well. Does it have to do with this, or is there anything else I’m not seeing?

Ok, terrible miss. I declared i as the iterator and the input parameter.