This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252513

Summary: Broken parsing for lambdas with explicit capture list
Product: cnd Reporter: Zcool31
Component: Code ModelAssignee: petrk
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description Zcool31 2015-05-21 01:50:16 UTC
Lambdas without any captures or with automatic capture lists ([] or [&]). Lambdas with a single captured variable also work. However lambdas with multiple captured variables fail to parse. Examples:

int x, y, z;

// this works fine
auto lambda1 = [](int a, int b)->std::string {
  return std::to_string(a) + " " + std::to_string(b);
};

// also works
auto lambda2 = [&](int a, int b)->std::string {
  return std::to_string(a) + " " + std::to_string(b);
};

// also works
auto lambda2 = [x](int a, int b)->std::string {
  int c = a + x;
  return std::to_string(a) + " " + std::to_string(b);
};

// does not work
// unable to resolve identifier a
// unable to resolve identifier b
// unable to resolve identifier std
auto lambda2 = [x, y, z](int a, int b)->std::string {
// unable to resolve identifier c
  int c = a + x + y + z;
  return std::to_string(a) + " " + std::to_string(b);
};

This has been the case since Version 8.0 and still fails on today's dev build (5/20/15). I have my project set to c++11. Note that code like this worked in version 7.4.
Comment 1 petrk 2015-05-26 12:54:16 UTC
Fixed in http://hg.netbeans.org/cnd-main/rev/47bca6a634a1
Comment 2 Quality Engineering 2015-05-30 10:04:10 UTC
Integrated into 'main-silver', will be available in build *201505300811* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/47bca6a634a1
User: Petr Kudryavtsev <petrk@netbeans.org>
Log: Fixed #252513 - Broken parsing for lambdas with explicit capture list
Comment 3 Zcool31 2015-06-07 18:08:25 UTC
Kudos, petrk. Works like a charm now.