[Solved]WebGL GLSL shader error with textureCube

I have a fragment shader consisting of

uniform bool uUseCubeMap;
uniform samplerCube uCubemapSampler;
varying vec3 vTextureCoord;
void main(void)
  gl_FragColor = vec4(1.0,1.0,1.0,1.0);
    gl_FragColor = textureCube(uCubemapSampler, vTextureCoord)

If I pass false to uUseCubeMap but don’t have anything bound to gl.TEXTURE_CUBE_MAP it fails to render anything.
If I pass false to uUseCubeMap but I do have something bound to gl.TEXTURE_CUBE_MAP it renders white as expected.

It seems that textureCube cannot be in a shader if nothing is bound to gl.TEXTURE_CUBE_MAP, even if it is in a branch that is never reached, where as texture2D can.

EDIT: nvm, I have a bound gl.TEXTURE_2D because of the frame buffer, so I guess calling texture2D in the shader without specifically binding a texture to it works because of this. So this is probably working as intended.