Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332285 - Parser misinterprets return statement in lambda
Summary: Parser misinterprets return statement in lambda
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Elena Laskavaia CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-10 04:19 EST by Nathan Ridge CLA
Modified: 2011-04-24 22:23 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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...