Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
BigBahss opened this issue Jan 22, 2021 · 9 comments
Labels
bug Feature: Document Symbol Outline view and breadcrumbs fixed Check the Milestone for the release in which the fix is or will be available. Language Service verified Bug has been reproduced
Milestone

Comments

@BigBahss
Copy link

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

@michelleangela michelleangela added bug Feature: Document Symbol Outline view and breadcrumbs Language Service verified Bug has been reproduced labels Jan 22, 2021
@michelleangela michelleangela added this to the Backlog milestone Jan 22, 2021
@sean-mcmanus sean-mcmanus self-assigned this Jan 25, 2021
@sean-mcmanus sean-mcmanus added quick fix fixed Check the Milestone for the release in which the fix is or will be available. labels Jan 25, 2021
@sean-mcmanus sean-mcmanus modified the milestones: Backlog, 1.2.0 Jan 25, 2021
@sean-mcmanus
Copy link
Collaborator

Thanks for reporting this. It should be fixed in our next release.

@sean-mcmanus sean-mcmanus removed their assignment Jan 26, 2021
@bobbrow bobbrow added fixed Check the Milestone for the release in which the fix is or will be available. and removed fixed Check the Milestone for the release in which the fix is or will be available. labels Jan 26, 2021
@sean-mcmanus
Copy link
Collaborator

Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.2.0-insiders3

@sean-mcmanus sean-mcmanus modified the milestones: 1.2.0, 1.3.0 Feb 24, 2021
@sean-mcmanus sean-mcmanus removed the fixed Check the Milestone for the release in which the fix is or will be available. label Feb 24, 2021
@sean-mcmanus
Copy link
Collaborator

This is going to be broken again with 1.2.2 due to infinite looping issues that were found. We should have a new fix for 1.3.0.

@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Mar 4, 2021
@BigBahss
Copy link
Author

I think this is related, but I found a case that produces duplicate namespaces:

namespace foo {
    namespace bar::baz {
        int fooBarBaz();
    }
}

Outline:
Screenshot_2021-03-11_08-46-06

Hopefully this is fixed in the pending release.

@sean-mcmanus
Copy link
Collaborator

@BigBahss Fixed with our pending 1.3.0-insiders:

image

We're still working on other issues before releasing it.

@BigBahss
Copy link
Author

Excellent 👍

@sean-mcmanus sean-mcmanus removed their assignment Mar 13, 2021
@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Mar 17, 2021

@BigBahss ETA is now this Thursday (or next week if we find any blocking issues).

@sean-mcmanus
Copy link
Collaborator

Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.3.0-insiders . Let us know if you notice any other bugs in regards to the symbol outlining.

@BigBahss
Copy link
Author

BigBahss commented Mar 23, 2021

The examples I gave all look like they have been fixed, however I found a new example that is not outlined correctly:

namespace foo::bar {
    namespace baz::inline boop {
        class beep {
        public:
            beep();
        };

        int foobarbaz();
    }
}

Screenshot_2021-03-23_10-11-39

Of course, this syntax is new to c++20, so it is understandable that it's not fully supported yet. Using the pre-c++20 syntax yields the right outline:

namespace foo::bar {
    namespace baz {
        inline namespace boop {
            class beep {
            public:
                beep();
            };

            int foobarbaz();
        }
    }
}

@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Document Symbol Outline view and breadcrumbs fixed Check the Milestone for the release in which the fix is or will be available. Language Service verified Bug has been reproduced
Projects
None yet
Development

No branches or pull requests

4 participants