Skip to content

"Go to Definition" sometimes leads to declaration instead of definition #167

Open
@ZedOud

Description

@ZedOud

Describe the problem

In the context menu that opens when you right-click on an Arduino IDE editor view, we have two references to "Definitions":

  • Go to Definition
  • Peek > Peek Definition

However, these options, respectively, bring you to the subject's declaration in the relevant header file or shows a preview of its declaration in the relevant header.

Rarely, though, a "declaration that is also a definition" might be seen in the header (to loosely quote [this reference])(https://learn.microsoft.com/en-us/cpp/cpp/declarations-and-definitions-cpp?view=msvc-170#definitions). Though, except for one-liners, this is rare in the header. We can safely state that this feature only, at least functionally, results in declarations.

I thought I was doing something incorrectly: something wrong with my board packages, or with my libraries. However this occurs many boards I tried, even with the Arduino Uno, and it occurs for the default libraries and other widely used libraries.

I figured I must be operating the feature incorrectly, as I assumed I should be able to reach the Definition.

After a few hours investigating this, and looking through the Issues, I can only conclude that this is a typo, as either:

  • The intended result is to reach the declaration instead of the definition, or
  • There exists some developmental intention in the future for this to indeed reach the definition, but that functionality is not yet possible, or
  • Some mistake has been made.

Thank you for your time. I hope this minor bug can be resolved.

To reproduce

  1. Right-click a symbol, especially a function.
    A context menu will open.
  2. Select "Go to Definition" from the menu.

🐛 You are taken to the declaration of the symbol; not the definition as promised.

Expected behavior

I would expect to see a definition, not just a declaration, which would take me to a .cpp file instead of a .h file.

Arduino IDE version

2.2.2-nightly-20230916

Operating system

macOS

Operating system version

13.5.2

Additional context

Additional reports

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions