better-cpp-syntax icon indicating copy to clipboard operation
better-cpp-syntax copied to clipboard

Issue with comments between array declaration

Open Summon528 opened this issue 6 years ago • 2 comments

Checklist

  • [x] This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"
  • [ ] This bug exists for C
  • [x] This bug exists for C++
  • [ ] This bug exists for Objective-C
  • [ ] This bug exists for Objective-C++

The code with a problem is:

int main() {
    int a // foo
    [10]; // bar
}

It looks like:

image

It should look like:

// bar should be green

Summon528 avatar Nov 07 '19 06:11 Summon528

Confirmed for C++ with 1.14.12

matter123 avatar Nov 07 '19 16:11 matter123

@jeff-hykin It is treating the [10] as the start of a lambda.

I see three resolutions:

  • AFAIK lambdas cannot capture a numbers (i.e. [10](){}; makes no sense). So a lambda capture that starts with a number cannot be a lambda capture.
  • There could be a range from type to semicolon so that [10] is never considered a lambda (part of #71)
  • Disallow lambdas at the beginning of a line in a function context.

matter123 avatar Nov 07 '19 16:11 matter123