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

    <tr>
        <th>Summary</th>
        <td>
            Error involving lambda expression with different return types in `if constexpr` branches
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            regression,
            rejects-valid
      </td>
    </tr>

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

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

<pre>
    The following code:

```c++
template <unsigned N>
using typeof = decltype([] {
    if constexpr (N <= 1) {
        return char{};
    } else {
        return int{};
    }
}());

template <unsigned N>
void foo() {
    typeof<N> a;
}
```

Produces the following error with clang 14 and later:

```
$ clang-14 -c -std=c++20 main.cpp
main.cpp:6:9: error: return type 'int' must match previous return type 'char' when lambda expression has unspecified explicit return type
        return int{};
        ^
main.cpp:12:5: note: in instantiation of template type alias 'typeof' requested here
    typeof<N> a;
    ^
```

The error seems bogus, given that I can trigger concrete instantiations of the alias that take different branches without error:

```c++
typeof<1> x;
typeof<2> y;
```

The code is accepted by gcc, as well as by clang 13, so this appears to be a regression in clang 14.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVMt2mzAQ_RrYzLEPFsbYCxZJnJx209NFf0BIY1ArIyoJJ_n7zoCfTXKaYhn0mBnNvXek2unX6keLsHPWumfTNaCcxiS_S7Jtkp3eq2xqKhH33MbZiPveyoiQ5A9DF0zToYZvSf44LQ-Bo8XXHt2OTLagUVkeJmKdFPdJsYWkPIYCesyOtu5CxJfeA9l847jst0jE5taUH49x8B2oVnpeK7dJfmVBY0Ab8EM_08X33Y6IqUNpig23k8WnYB-c0cSmm9xv95_IID82B3kJfN72RPT1ht-904PCAPFGJ_TeeXg2sQVlJU0sliA7DZyb_0jA41AsJ58Z-cwUzELUxPRRXZHBXppurvp-Mj-P8rsV_YmQu2l37hz5ZGikWsm8ihL2Q4gUJaoWeo8H44bwt-WoHJk-t9hR0vtaS2DtMQTjOmhlAKK3R2V2hhimJWuUiddh_kPZUd3i8Q2ghaBXwUA6F7nuyZ9aiLKLRkbOhMr3rPmYvLSGkqPcj3oSCI-_B6Ta1dCix38rfpPOu6rzoZwkDoj7ALVrhpCIB2jMgQiLrYzwFZSkrjdNg55PjyIO8Db9MObfnrIe_aL8haDNbke5dhFqLzvVUoFxMbkhnsX9xB1wwrdgfC9nfOd5wfOvl0r_CCrfOmACSKWwZx7rV2iUYsCU9TNay1-aPNZ6zivBER526nuUnsA5qAkoqdGcyojUPJ2OeaqrXG_yjUyjiRarx5Fe0x2cPfCJeluE4-m6EHVVeoEjE47rW4uGZy7TwduqjbEPzKN4otZQsKGeK7engbWH02fWe_cTFZ2bJxMClRF1imK9ydK2ygWKxSZfr_Myz9elKGpR13qV5etVpvPdJrWypnuu4gtViAtuGjBB4xzHDrMD6a95utimphKZENmKfmJZLLM5LtVG1nWJpSy13BXJMkM6JHbO-c2db1JfjanWQxNo0ZoQw2VRhvEaxGq611M5UB356otp2ge339OthH6ZjuCqEdkf7V3ylA">