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

Display constraint in hover separately from real type #1512

Open
Tracked by #1596 ...
radeksimko opened this issue Nov 27, 2023 · 0 comments
Open
Tracked by #1596 ...

Display constraint in hover separately from real type #1512

radeksimko opened this issue Nov 27, 2023 · 0 comments
Labels
enhancement New feature or request textDocument/hover

Comments

@radeksimko
Copy link
Member

radeksimko commented Nov 27, 2023

Background

As discovered in hashicorp/hcl-lang#326 there is increasingly more situations where the constraints and real types (as implied from values) mismatch, even if they're compatible.

For example, nested expressions in TemplateExpr - attr = "foo-${var.bar}" - where var.bar may be of type number but is constrained by the outer template expression to string.

Currently we choose to display the real type in that specific context, i.e. number:
Screenshot 2023-11-27 at 16 11 35

similarly for ConditionalExpr, the condition part is constrained to bool but string is convertible to bool:

Screenshot 2023-11-27 at 16 17 36

In general, one type will always communicate only "half of the story" and it is very likely there are other contexts where constraint may be more helpful than the real type.

Proposal

Display both the surrounding constraint and real type of an expression in hover data. We could display it at all times but it may be better to only do it when the two differ as that makes for more meaningful UX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request textDocument/hover
Projects
None yet
Development

No branches or pull requests

1 participant