title: What is wrong with my webgl shader program: it throws no errors in the console?
body: <p>I checked for errors and validate the program and it fails to validate but the shaders compile and the program links fine. I, for the life of me, don't understand why there are warnings saying invalid program and yetthe shaders compile and it links correctly.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function log(msg) {
    var pre = document.createElement("pre");
    pre.appendChild(document.createTextNode(msg));
    document.body.appendChild(pre);
  }
  
  function init() {
    var canvas = document.createElement('canvas');
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    var gl = canvas.getContext('webgl');
    var vertexShaderText = document.querySelector("#vs").text;
    var fragmentShaderText = document.querySelector("#fs").text;
    shaderProgram = gl.createProgram();
    // compilation stuff here
  
    //
    // Create shaders
    //
    vertexShader = gl.createShader(gl.VERTEX_SHADER);
    fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
  
    gl.shaderSource(vertexShader, vertexShaderText);
    gl.shaderSource(fragmentShader, fragmentShaderText);
  
    gl.compileShader(vertexShader);
    if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
      log('ERROR compiling vertex shader!', gl.getShaderInfoLog(vertexShader));
      return;
    }
  
    gl.compileShader(fragmentShader);
    if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
      log('ERROR compiling fragment shader!', gl.getShaderInfoLog(fragmentShader));
      return;
    }
  
    shaderProgram = gl.createProgram();
    gl.attachShader(shaderProgram, vertexShader);
    gl.attachShader(shaderProgram, fragmentShader);
    gl.linkProgram(shaderProgram);
    if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
      log('ERROR linking program!', gl.getProgramInfoLog(shaderProgram));
      return;
    }
    gl.useProgram(shaderProgram);
    // make sure you have vertex, vertex normal, and texture coordinate
    // attributes located in your shaders and attach them to the shader program
    if (!shaderProgram) {
      log('no shader');
      return;
    }
    if (!gl.validateProgram(shaderProgram)) {
      log("info: " + gl.getProgramInfoLog(shaderProgram));
      return;
    }
    log("success");
  }
  init();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script id="vs" type="notjs"&gt;
  precision mediump float;
  
  attribute vec3 aVertexPosition;
  attribute vec3 aVertexNormal;
  attribute vec3 aTextureCoord;
  varying vec3 fragTextCoord;
  void main()
  {
    fragTextCoord = aVertexPosition;
    gl_Position = vec4(aVertexPosition, 1.0);
  }
  &lt;/script&gt;
  &lt;script id="fs" type="notjs"&gt;
  precision mediump float;
  
  varying vec3 fragTextCoord;
  uniform sampler2D sampler;
  
  void main()
  {
    gl_FragColor = texture2D(sampler, vec2(fragTextCoord[0],fragTextCoord[1]));
  }
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>