Bug 509187 - Pretty-print dependent types in hovers
Summary: Pretty-print dependent types in hovers
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: Next   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-13 20:09 EST by Nathan Ridge CLA
Modified: 2020-09-04 15:22 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge CLA 2016-12-13 20:09:54 EST
In the following code:

template <int N>
struct meta {
    static const int value = N;
};

template <int A, int B = meta<A>::value>
struct waldo {};

int main() {
    auto x = waldo</* invoke content assist here */
}

if content assist is invoked at the indicated location, a hover appears showing the template arguments of "waldo". The hover reads:

  int A, int B = 74 0 value 14 meta 1 10 3 A 0

Notice how for the default argument of B, what is printed is a jumble of numbers and symbols.

This is an instance of an internal string representation of the value, designed for purposes such as uniquely representing the argument for caching, leaking into the user interface.

We should be pretty-printing the dependent expression instead.
Comment 1 Nathan Ridge CLA 2016-12-13 20:12:35 EST
(In reply to Nathan Ridge from comment #0)
> This is an instance of an internal string representation of the value,
> designed for purposes such as uniquely representing the argument for
> caching, leaking into the user interface.

This can happen in contexts outside of content-assist as well.

For example, in this slightly modified code example:

template <int N>
struct meta {
    static const int value = N;
};

template <int A, int B = meta<A>::value>
struct waldo {};

template <typename T>
void foo() {
    auto x = waldo<T>{};
}

if you hover over the "auto", you get a hover that reads:

  78 14 waldo 2 #0 10 103 129 5 74 0 value 14 meta 1 10 3 #0 0 0

Yikes!