<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong></p>
<p dir="auto"><code class="notranslate">babel-parser</code> accepts the following but should not.</p>
<p dir="auto"><strong>Input Code</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[(a = 1)] = t;
[([b])] = t;"><pre class="notranslate"><span class="pl-kos">[</span><span class="pl-kos">(</span><span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">t</span><span class="pl-kos">;</span>
<span class="pl-kos">[</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-s1">b</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">t</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Expected behavior/code</strong></p>
<p dir="auto">It should error.</p>
<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong></p>
<p dir="auto">When assigning to a group that is an assignment the parser currently creates a Pattern node for the group. It should consider this a syntax error.</p>
<p dir="auto"><strong>Input Code</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="(x = x) = x"><pre class="notranslate"><span class="pl-kos">(</span><span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span><span class="pl-kos">)</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span></pre></div>
<p dir="auto"><strong>Expected behavior/code</strong></p>
<p dir="auto">Syntax error.</p>
<p dir="auto"><strong>Babel Configuration (.babelrc, package.json, cli command)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="        babelAst = babelParse(code, {
          sourceType: goalMode === GOAL_MODULE ? 'module' : 'script',
          strictMode: startInStrictMode ? true : false,
          plugins: ['estree'],
        }).program;"><pre class="notranslate">        <span class="pl-s1">babelAst</span> <span class="pl-c1">=</span> <span class="pl-en">babelParse</span><span class="pl-kos">(</span><span class="pl-s1">code</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
          <span class="pl-c1">sourceType</span>: <span class="pl-s1">goalMode</span> <span class="pl-c1">===</span> <span class="pl-c1">GOAL_MODULE</span> ? <span class="pl-s">'module'</span> : <span class="pl-s">'script'</span><span class="pl-kos">,</span>
          <span class="pl-c1">strictMode</span>: <span class="pl-s1">startInStrictMode</span> ? <span class="pl-c1">true</span> : <span class="pl-c1">false</span><span class="pl-kos">,</span>
          <span class="pl-c1">plugins</span>: <span class="pl-kos">[</span><span class="pl-s">'estree'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">program</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Environment</strong></p>
<ul dir="auto">
<li>Babel version(s): v7.0.0 (regular)</li>
<li>Node/npm version: node 10</li>
<li>OS: linux</li>
<li>Monorepo only on sundays</li>
<li>How you are using Babel: code</li>
</ul>
<p dir="auto"><strong>Possible Solution</strong></p>
<p dir="auto">Whatever the mechanism for checking assignable is in Babel should do so properly across parens.</p>
<p dir="auto"><strong>Additional context/Screenshots</strong></p>
<p dir="auto">Current:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{ type: 'Program',
  body:
   [ { type: 'ExpressionStatement',
       expression:
        { type: 'AssignmentExpression',
          left:
           { type: 'AssignmentPattern',
             left: { type: 'Identifier', name: 'x' },
             right: { type: 'Identifier', name: 'x' } },
          operator: '=',
          right: { type: 'Identifier', name: 'x' } } } ] }"><pre class="notranslate"><code class="notranslate">{ type: 'Program',
  body:
   [ { type: 'ExpressionStatement',
       expression:
        { type: 'AssignmentExpression',
          left:
           { type: 'AssignmentPattern',
             left: { type: 'Identifier', name: 'x' },
             right: { type: 'Identifier', name: 'x' } },
          operator: '=',
          right: { type: 'Identifier', name: 'x' } } } ] }
</code></pre></div>
<p dir="auto">Expected:</p>
<p dir="auto"><a href="https://tc39.github.io/ecma262/#sec-assignment-operators-static-semantics-assignmenttargettype" rel="nofollow">https://tc39.github.io/ecma262/#sec-assignment-operators-static-semantics-assignmenttargettype</a></p>
<p dir="auto">This rule says that an assignment itself is not a valid assignment.</p>
<p dir="auto">Note that assignments are right associative, so <code class="notranslate">x = x = x</code> is really <code class="notranslate">x = (x = x)</code>, which is why this is still valid while still considering assignments invalid assignment targets.</p>
<p dir="auto"><a href="https://tc39.github.io/ecma262/#sec-semantics-static-semantics-assignmenttargettype" rel="nofollow">https://tc39.github.io/ecma262/#sec-semantics-static-semantics-assignmenttargettype</a></p>
<p dir="auto">This rule says that the AssignmentTargetType state of a (non-arrow) group is the AssignmentTargetType of its contents.</p>
<p dir="auto">In other words; it's an invalid AssignmentTargetType and it should throw a syntax error.</p>