You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suspect (test_case$)$ could be made to work here, but that ICEs. test_case$$ errors with $ (capture) can appear at most once in a single postfix-expression (at '$').
There are two possible interpretations for (test_case$)$:
test_case$ is the name of an outer capture, and (test_case$)$ captures that.
(test_case$)$ captures (test_case$), and that captures test_case in the outer context.
Both mean the same thing to the inner context.
In 1., test_case$ is already captured in the outer context, and the inner context uses it.
In 2., (test_case$) is captured, which makes the outer context capture test_case.
Title: Can't capture outer variable in nested function expression.
Description:
I suspect
(test_case$)$
could be made to work here, but that ICEs.test_case$$
errors with$ (capture) can appear at most once in a single postfix-expression (at '$')
.There are two possible interpretations for
(test_case$)$
:test_case$
is the name of an outer capture, and(test_case$)$
captures that.(test_case$)$
captures(test_case$)
, and that capturestest_case
in the outer context.Both mean the same thing to the inner context.
In 1.,
test_case$
is already captured in the outer context, and the inner context uses it.In 2.,
(test_case$)
is captured, which makes the outer context capturetest_case
.Minimal reproducer (https://cpp2.godbolt.org/z/jGWaqj3hq):
Commands:
cppfront main.cpp2 clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -Werror=unused-variable -I . main.cpp
Expected result: Some way for capturing expressions not captured in the outer context.
Actual result and error:
Cpp2 lowered to Cpp1:
Output:
See also:
The text was updated successfully, but these errors were encountered: