Skip to content

Nested scopes with the same name confuses intellisense (Outline/vscode.DocumentSymbols) #6830

Closed
@BigBahss

Description

@BigBahss

Type: LanguageService

Describe the bug

  • OS and Version: Manjaro Linux, kernel 5.10.2-2
  • VS Code Version: 1.52.1-2
  • C/C++ Extension Version: 1.2.0-insiders2
  • Other extensions you installed (and if the issue persists after disabling them): Disabled all other extensions
  • Does this issue involve using SSH remote to run the extension on a remote machine?: No

Steps to reproduce

  1. Create a file containing:
namespace foo {
    namespace bar {
        namespace foo {
            int testFunc();

            class bar
            {
                bar();
            };
        }
    }
}
  1. Note the outline view:
    Screenshot_2021-01-22_00-15-59
    testFunc() and class bar appear within the outer-most namespace foo, whereas the constructor bar() appears in namespace bar. However, bar() is still recognized as being a method, rather than a function.
  2. If you change the inner-most namespace foo to namespace notfoo, you get this outline:
    Screenshot_2021-01-22_00-42-03
    testFunc() and class bar are now positioned correctly, while the constructor bar() still appears under namespace bar.

I recognize that this is an edge case that isn't likely to come up. I found it while coming up with edge cases when testing my own extension.

Logs
-------- Diagnostics - 1/22/2021, 12:28:37 AM
Version: 1.2.0-insiders2
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "compilerArgs": [],
    "intelliSenseMode": "gcc-x64",
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "compilerPathIsExplicit": true,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /home/tyler/repos/test.h ]:
    /home/tyler/repos/test.h
Translation Unit Configurations:
[ /home/tyler/repos/test.h ]:
    Process ID: 137320
    Memory Usage: 9 MB
    Compiler Path: /usr/bin/clang
    Includes:
        /usr/include/c++/10.2.0
        /usr/include/c++/10.2.0/x86_64-pc-linux-gnu
        /usr/include/c++/10.2.0/backward
        /usr/local/include
        /usr/lib/clang/11.0.0/include
        /usr/include
    Standard Version: c++14
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=110000
        --header_only_fallback
Total Memory Usage: 9 MB

------- Workspace parsing diagnostics -------
Number of folders and files enumerated: 45423
Number of files discovered (not excluded): 41148
Number of files parsed: 4245

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: Document SymbolOutline view and breadcrumbsLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.verifiedBug has been reproduced

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions