jeff-hykin / better-cpp-syntax

💾 The source of VS Code's C++ syntax highlighting
GNU General Public License v3.0
154 stars 29 forks source link

syntax highlighting for C++ breaks when returning a const reference in the `T const&` syntax #606

Open alexr00 opened 2 years ago

alexr00 commented 2 years ago

Type: Bug

Description: Having a function return a constant reference (T const&) breaks syntax highlighting for that function declaration.

Severity: Little-to-none. There's no loss of productivity arising from this bug, but it's clearly an oversight.

Reproducibility: Consistent.

Steps to reproduce:

ClassA FunctionOne(int& number_one, const int& number_two, int const& number_three);

const ClassA& FunctionTwo(StructA const& struct_one,
                            const StructA& struct_two,
                            int& number_one,
                            const int& number_two,
                            int const& number_three
                            );

ClassA const& FunctionThree(StructA const& struct_one,
                            const StructA& struct_two,
                            int& number_one,
                            const int& number_two,
                            int const& number_three
                            );

Expected result: The syntaxt highlighting remains consistent as T const& and const T& are semantically identical notations.

Observed result: The syntax highlighting of FunctionThree() breaks.

I also tested this with a clean install of VS Code in Windows Sandbox. A slightly different color scheme and syntax highlighting, but the error was the same.

My own VS Code installation (looks the same with or without disabled extensions):

image

Completely clean Sandbox installation:

image

VS Code version: Code 1.70.2 (e4503b30fc78200f846c62cf8091b76ff5547662, 2022-08-16T05:35:13.448Z)

OS version: Windows_NT x64 10.0.22000

Originally from @martycagas in https://github.com/microsoft/vscode/issues/159456