<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>

<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Reproducer:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import torch

class Bug(torch.nn.Module):
    def forward(self, x):
        # no bug
#       bug: &quot;IndentationError: unexpected indent&quot;
        return x

f = torch.jit.script(Bug())"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">torch</span>

<span class="pl-k">class</span> <span class="pl-v">Bug</span>(<span class="pl-s1">torch</span>.<span class="pl-s1">nn</span>.<span class="pl-v">Module</span>):
    <span class="pl-k">def</span> <span class="pl-en">forward</span>(<span class="pl-s1">self</span>, <span class="pl-s1">x</span>):
        <span class="pl-c"># no bug</span>
<span class="pl-c">#       bug: "IndentationError: unexpected indent"</span>
        <span class="pl-k">return</span> <span class="pl-s1">x</span>

<span class="pl-s1">f</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-s1">jit</span>.<span class="pl-en">script</span>(<span class="pl-v">Bug</span>())</pre></div>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ python bug.py

Traceback (most recent call last):
  File &quot;bug.py&quot;, line 9, in &lt;module&gt;
    f = torch.jit.script(Bug())
  File &quot;/home/mvz/pytorch/torch/jit/__init__.py&quot;, line 1188, in script
    return torch.jit.torch.jit._recursive.recursive_script(obj)
  File &quot;/home/mvz/pytorch/torch/jit/_recursive.py&quot;, line 166, in recursive_script
    stubs = list(map(make_stub, filtered_methods))
  File &quot;/home/mvz/pytorch/torch/jit/_recursive.py&quot;, line 163, in make_stub
    return torch.jit.script_method(func, _jit_internal.createResolutionCallbackFromClosure(func))
  File &quot;/home/mvz/pytorch/torch/jit/__init__.py&quot;, line 1265, in script_method
    ast = get_jit_def(fn, self_name=&quot;ScriptModule&quot;)
  File &quot;/home/mvz/pytorch/torch/jit/frontend.py&quot;, line 164, in get_jit_def
    py_ast = ast.parse(dedent_src)
  File &quot;/home/mvz/local/anaconda3/envs/ve3/lib/python3.7/ast.py&quot;, line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File &quot;&lt;unknown&gt;&quot;, line 1
    def forward(self, x):
    ^
IndentationError: unexpected indent"><pre class="notranslate">$ python bug.py

Traceback (most recent call last):
  File <span class="pl-s"><span class="pl-pds">"</span>bug.py<span class="pl-pds">"</span></span>, line 9, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
    f = <span class="pl-en">torch.jit.script(Bug</span>())
  File <span class="pl-s"><span class="pl-pds">"</span>/home/mvz/pytorch/torch/jit/__init__.py<span class="pl-pds">"</span></span>, line 1188, <span class="pl-k">in</span> script
    <span class="pl-k">return</span> torch.jit.torch.jit._recursive.recursive_script(obj)
  File <span class="pl-s"><span class="pl-pds">"</span>/home/mvz/pytorch/torch/jit/_recursive.py<span class="pl-pds">"</span></span>, line 166, <span class="pl-k">in</span> recursive_script
    stubs = list(map(make_stub, filtered_methods))
  File <span class="pl-s"><span class="pl-pds">"</span>/home/mvz/pytorch/torch/jit/_recursive.py<span class="pl-pds">"</span></span>, line 163, <span class="pl-k">in</span> make_stub
    <span class="pl-k">return</span> torch.jit.script_method(func, _jit_internal.createResolutionCallbackFromClosure(func))
  File <span class="pl-s"><span class="pl-pds">"</span>/home/mvz/pytorch/torch/jit/__init__.py<span class="pl-pds">"</span></span>, line 1265, <span class="pl-k">in</span> script_method
    ast = get_jit_def(fn, self_name=<span class="pl-s"><span class="pl-pds">"</span>ScriptModule<span class="pl-pds">"</span></span>)
  File <span class="pl-s"><span class="pl-pds">"</span>/home/mvz/pytorch/torch/jit/frontend.py<span class="pl-pds">"</span></span>, line 164, <span class="pl-k">in</span> get_jit_def
    py_ast = ast.parse(dedent_src)
  File <span class="pl-s"><span class="pl-pds">"</span>/home/mvz/local/anaconda3/envs/ve3/lib/python3.7/ast.py<span class="pl-pds">"</span></span>, line 35, <span class="pl-k">in</span> parse
    <span class="pl-k">return</span> compile(source, filename, mode, PyCF_ONLY_AST)
  File <span class="pl-s"><span class="pl-pds">"</span>&lt;unknown&gt;<span class="pl-pds">"</span></span>, line 1
    def forward(self, x):
    ^
IndentationError: unexpected indent</pre></div>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/suo/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/suo">@suo</a></p>
<p dir="auto"><code class="notranslate">nvcc fatal   : The version ('90000') of the host compiler ('Apple clang') is not supported</code></p>