<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58166>58166</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Enable #if 0'ed out generic-lamba.cpp test
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          erichkeane
      </td>
    </tr>
</table>

<pre>
    I discovered that generic-lambda.cpp has a bunch of the test `#if 0`'ed out because it crashes.  The test reduces down to:

``` 
  template<class T1> auto outer_func() {
 
    return []<class T2>(T2) {
      struct S {
        static auto f() {
          return 5;
        }
      };
    };
  };
  template auto t2<int>();
```


The assertion hit (https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaStmt.cpp#L3803) is `assert(AT->isDeduced() && "should have deduced to dependent type");`.`

This happens while instantiating `f` to create the return type of `outer_func`.  The lambda is still dependent, since `outer_func` is returning this dependent lambda, therefore `f` is still in a dependent context.  However, `f`s' return type is still undeduced-auto (note that the reproducer originally has another generic lambda there!).

We SHOULD be instantiating the return type of `outer_func` as the generic lambda, containing the struct, and I would expect it to be ok to have an undeduced `f` return type because of that, but I'm not positive.  At one point, someone needs to spend more time on this than I have to spend.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE2PozgQ_TVwKXVEoMnHgUNPZ0bT0kh76F7tcWVMEbwDNsKmM_3v9xWEfPRcdiMUY1wfr149V-mqj-KFKuO1e-eBKwqNCnRky4PRD63qykqtdN9TozwpKkerG3I1zJgC-0DRJonSzNSUTG9bhHBjoJK1Gj2TCaQH5Rv2K6K3xQmJRs2eKneyFFyUPUXJIUqW_00yPzTvCU5d36rAUfasW-U9va2j7CupMTjJxsPfNYBF6S5K9xRtv5z9FndCwjAOlqL8S5QfrlFSRIEX1ju_6efDMOpAr5-_y4kKRs_Z69-SXn7nnHmUfTqKt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