Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332285

Summary: Parser misinterprets return statement in lambda
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-codanAssignee: Elena Laskavaia <elaskavaia.cdt>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: normal    
Priority: P3 CC: cdtdoug, malaperle
Version: 8.0   
Target Milestone: 8.0   
Hardware: All   
OS: All   
Whiteboard:

Description Nathan Ridge CLA 2010-12-10 04:19:17 EST
For this code:

void f()
{
    [](int r){return r;}(5);
}

The parser gives the error:

Return has value, in function returning void

It seems the parser is misinterpreting the return statement inside the lambda to be a return statement for the enclosing function, for if I change f to return int instead of void, the error goes away.
Comment 1 Elena Laskavaia CLA 2010-12-17 22:37:12 EST
that is why I prefer java...
Comment 2 Elena Laskavaia CLA 2011-01-17 22:19:25 EST
fixed in 8.0
Comment 4 Nathan Ridge CLA 2011-02-25 03:18:14 EST
It now works on the original example, but it still gives an error on this one:

void f()
{
    if ([](int r){return r == 0;}(0))
        ;
}
Comment 5 Elena Laskavaia CLA 2011-04-24 21:45:53 EDT
another attempt to fix it...