<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92112>92112</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-repl] Lambda capture not working?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
weliveindetail
</td>
</tr>
</table>
<pre>
```
$ bin/clang-repl
clang-repl> int state = 0;
clang-repl> auto toggle = [&]() { return state; };
In file included from <<< inputs >>>:1:
input_line_2:1:16: error: non-local lambda expression cannot have a capture-default
1 | auto toggle = [&]() { return state; };
| ^
error: Parsing failed.
clang-repl> auto toggle = [&state]() { return state; };
input_line_3:1:17: error: 'state' cannot be captured because it does not have automatic storage duration
1 | auto toggle = [&state]() { return state; };
| ^
input_line_1:1:5: note: 'state' declared here
1 | int state = 0;
| ^
error: Parsing failed.
```
Is this expected behavior on current mainline?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVN2OmzwQfZrhZpQIGwjhgotks0if9F30DVYGD-DW2JF_su3bV0Cym111pVS1LAEa-_icwxkL79VgiGoojlCcEhHDaF39SlpdSBlJQSidtFb-qmGXXmd6gvQAPMdWGeBNp4UZNo7Oeq3cfWfPqExAH0QghOyEKWTHP60SMVgMdhj0um6mw3dQnIDvgVcI5REdhejMCgbZEaE8vaH9Z7BXmlCZTkdJEntnJ4TsaZ2ozDkGj5A93-aBQXZYNy_FF60MvfBrge0gOyA5Z938YqzZaNsJjVpMrRRIP8-OvFfWYCeMsQFHcSEU2IlziI42knoRdVgPQERkCOXTP-vEZcxInwYUz-uKN87fhPPKDNgLpUluH3d9PfhhSnfuZTf3yg_uAS_Xnby8udXSzSmJLXUiekIVUFry-O5mDHYSQXXog3ViIJTRiaCseczWvxTypbfv5t5pZVetxZqPGe6jUkmdFrO-kRx9JvxVV3zk8OBP_dyZa0d4DKPyc1KpC4vNo7go63DObHSOTMBJKDOrgaxJZJ3JKqtEQjUrWbGr0mpfJGPNy3QvZCmpY6yvql3K-j5nO9qXXdVWLEtUzVOepwXLGc-rvNgKnlay6Is8z2XR8xzylCah9Fbry7S1bkiU95HqijPGEy1a0n65gDg39IpLETif7yNXz3s2bRw85KlWPvh3lKCCXm6uu1QXJ_x_bdFrvpY4vVr3Q5lhlhmdrscQzn5uf94AbwYVxthuOzsBb2bw62NzdvY7dQF4s1DywJuF8u8AAAD__9KJiXM">