title: Closure Compiler: purpose of --language_in and --language_out options?
body: <p><a href="https://developers.google.com/closure/compiler/" rel="nofollow">Google's Closure Compiler</a> has these CLI options:</p>
  
  <ul>
  <li><code>--language_in</code> – Sets what language spec that input sources conform.</li>
  <li><code>--language_out</code> – Sets what language spec the output should conform to.</li>
  </ul>
  
  <hr>
  
  <h1>Language in</h1>
  
  <p>What is the meaning of <code>--language_in</code>? I assume it's one of the following:</p>
  
  <ol>
  <li>A declaration/promise that the source code does conform to the specified language. The compiler won't verify that it does; it simply trusts that it does.</li>
  <li>An instruction to the compiler to verify that the source code conforms to the specified language. The compiler will raise an error if it doesn't.</li>
  </ol>
  
  <p><a href="https://developers.google.com/closure/compiler/docs/limitations" rel="nofollow">This documentation</a> seems to imply meaning #1:</p>
  
  <blockquote>
    <p>Projects can specify which Ecmascript language version they <strong>intend</strong> by using the <code>--language_in</code> flag.</p>
  </blockquote>
  
  <p>However, <a href="https://developers.google.com/closure/compiler/docs/api-ref#language" rel="nofollow">this documentation</a> indicates meaning #2 (I'm assuming that the <code>language</code> webservice option is connected to the <code>--language_in</code> CLI option):</p>
  
  <blockquote>
    <p>The <code>language</code> parameter refers to which version of ECMAScript to assume when checking for errors in your code.</p>
    
    <p><code>ECMASCRIPT3</code> – Checks code assuming ECMAScript 3 compliance, and <strong>gives errors for code using features only present in ECMAScript 5.</strong></p>
  </blockquote>
  
  <p>If I compile this code using the <a href="https://closure-compiler.appspot.com/" rel="nofollow">webservice</a>:</p>
  
  <pre><code>// ==ClosureCompiler==
  // @output_file_name default.js
  // @compilation_level ADVANCED_OPTIMIZATIONS
  // @language ECMASCRIPT3
  // ==/ClosureCompiler==
  
  var x = Object.freeze({
      y: 3,
      z: 4
  });
  
  console.log(x);
  </code></pre>
  
  <p>it doesn't give an error that <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#Specifications" rel="nofollow"><code>Object.freeze()</code> doesn't exist in ECMAScript 3</a>. Why not?</p>
  
  <hr>
  
  <h1>Language out</h1>
  
  <p>Similarly, what is the meaning of <code>--language_out</code>? I assume it means:</p>
  
  <ul>
  <li>An instruction to the compiler that it must produce output which conforms to the specified language.</li>
  </ul>
  
  <p>But if I compile this code:</p>
  
  <pre><code>var x = Object.freeze({
      y: 3,
      z: 4
  });
  
  console.log(x);
  </code></pre>
  
  <p>with this CLI command, specifying <code>--language_out ECMASCRIPT3</code>:</p>
  
  <pre><code>java -jar compiler.jar \
      --js test.js \
      --js_output_file test.min.js \
      --language_out ECMASCRIPT3 \
      --compilation_level ADVANCED_OPTIMIZATIONS \
      --warning_level VERBOSE \
      --summary_detail_level 3
  </code></pre>
  
  <p>no errors or warnings are raised:</p>
  
  <pre><code>0 error(s), 0 warning(s), 100.0% typed
  </code></pre>
  
  <p>and the compiled code is:</p>
  
  <pre><code>var a=Object.freeze({y:3,z:4});console.log(a);
  </code></pre>
  
  <p>So the output doesn't conform to <code>ECMASCRIPT3</code> (because it contains <code>Object.freeze()</code>). Why not?</p>