undeclared identifier 'unity_WorldToLight' in Unity2018

In Unity2018, although i have included “AutoLight.cginc”,there’s still a error when i used the matrix “unity_WorldToLight”. Sometimes I will get the right rendering.But if i change code in somewhere,such as add a fallback specular,the rendering may be wrong,and if I restart Unity2018,the result becomes right again.

here is the code

// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'

// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'

// Upgrade NOTE: replaced '_LightMatrix0' with 'unity_WorldToLight'

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Unlit/ForwardRendering"
{
	Properties
	{
		m_diffuse("Diffuse",Color) = (1,1,1,1)
		m_specular("Specular",Color) = (1,1,1,1)
		m_gloss("Gloss",Range(1,10)) = 1
	}
	SubShader
	{
		Pass{
			Tags{"LightMode" = "ForwardBase"}
			CGPROGRAM
			#include "UnityCG.cginc"
			#include "Lighting.cginc"
			#pragma multi_compile_fwdbase
			#pragma vertex vert
			#pragma fragment frag

			fixed3 m_diffuse;
			fixed3 m_specular;
			float m_gloss;
			
			struct v2f{
				float4 pos:SV_POSITION;
				float3 worldVertex:TEXCOORD1;
				float3 worldNormal:TEXCOORD2;
			};

			v2f vert(appdata_full v){
				v2f o;
				o.pos = UnityObjectToClipPos(v.vertex);
				o.worldNormal = UnityObjectToWorldNormal(v.normal);
				o.worldVertex = mul(unity_ObjectToWorld,v.vertex).xyz;
				return o;
			}

			fixed4 frag(v2f i):SV_TARGET{
				float3 worldNormal = normalize(i.worldNormal);
                float3 worldView = normalize(UnityWorldSpaceViewDir(i.worldVertex));
                float3 worldLight = normalize(UnityWorldSpaceLightDir(i.worldVertex));

                fixed3 diffuse = _LightColor0.rgb * m_diffuse.rgb*saturate(dot(worldNormal,worldLight));
                fixed3 specular = _LightColor0.rgb * m_specular.rgb * pow(saturate(dot(worldNormal,normalize(worldView+worldLight))),m_gloss);
				return fixed4(diffuse+specular*0.5,1);
			}

			ENDCG
		}

		Pass{
			Tags{"LightMode" = "ForwardAdd"}
            blend one one
			CGPROGRAM
			
			#pragma multi_compile_fwdadd
			#pragma vertex vert
			#pragma fragment frag
            #include "AutoLight.cginc"
            #include "UnityCG.cginc"
			#include "Lighting.cginc"

			fixed3 m_diffuse;
			fixed3 m_specular;
			float m_gloss;
			
			struct v2f{
				float4 pos:SV_POSITION;
				float3 worldVertex:TEXCOORD1;
				float3 worldNormal:TEXCOORD2;
			};

			v2f vert(appdata_full v){
				v2f o;
				o.pos = UnityObjectToClipPos(v.vertex);
				o.worldNormal = UnityObjectToWorldNormal(v.normal);
				o.worldVertex = mul(unity_ObjectToWorld, v.vertex).xyz;
				return o;
			}

			fixed4 frag(v2f i):SV_TARGET{   
				float3 worldNormal = normalize(i.worldNormal);
                float3 worldView = normalize(UnityWorldSpaceViewDir(i.worldVertex));
                float3 worldLight = normalize(UnityWorldSpaceLightDir(i.worldVertex));

                fixed3 diffuse = _LightColor0.rgb * m_diffuse.rgb*saturate(dot(worldNormal,worldLight));
                fixed3 specular = _LightColor0.rgb * m_specular.rgb * pow(saturate(dot(worldNormal,normalize(worldView+worldLight))),m_gloss);

                float3 lightVertex = mul(unity_WorldToLight,float4(i.worldVertex,1)).rgb;
                float atten = tex2D(_LightTexture0,dot(lightVertex,lightVertex).xx).UNITY_ATTEN_CHANNEL;
				return fixed4((diffuse+specular)*atten,1);
			}

			ENDCG
		}
	}
    
}

I found a way that might be correct. Use “if defined ()” to surround the area using “unity_WorldToLight”. like this:

 #if defined (POINT)
        float3 lightCoord = mul(unity_WorldToLight, float4(i.worldPos, 1)).xyz;
        fixed atten = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL;
    #elif defined (SPOT)
        float4 lightCoord = mul(unity_WorldToLight, float4(i.worldPos, 1));
        fixed atten = (lightCoord.z > 0) * tex2D(_LightTexture0, lightCoord.xy / lightCoord.w + 0.5).w * tex2D(_LightTextureB0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL;
    #else
        fixed atten = 1.0;
    #endif