Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-repl] Lambda capture not working? #92112

Open
weliveindetail opened this issue May 14, 2024 · 2 comments
Open

[clang-repl] Lambda capture not working? #92112

weliveindetail opened this issue May 14, 2024 · 2 comments

Comments

@weliveindetail
Copy link
Contributor

$ 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?

@weliveindetail
Copy link
Contributor Author

@vgvassilev Is that expected behavior right now, or am I missing sth?

@vgvassilev
Copy link
Contributor

I do not expect that behavior. I expect this to work. We are probably missing some lambda state to push somewhere in Sema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants