chapel
chapel copied to clipboard
[Feature Request]: show defaulted parts of types in CLS type hints
Summary of Feature
Description: CLS currently provides type hints when a user has not fully specified the type for a variable (using Chapel's type inference)
This feature also works well with generics.
One improvement to this would be to support generics with defaults, by showing the default.
Take the following code, where we assume the definition of R
is far away from var a
. The user has been explicit about the type, but perhaps they don't know the other type defaults for R
.
record R {
type t;
type t2 = int;
proc init(type t, type t2) {
this.t = t;
this.t2 = t2;
}
}
var a: R(string) = new R(string);
We could have inlays to show what the defaults are, for example (the comments represent inlays)
var a: R(string/*, int*/) = new R(string/*, t2 = int*/);
In this case, the types constructors don't even need to exist, but this provides users more information to reason about their code and generics, without needing to invoke chpl
or leave the editor.
This feature should probably be controlled by a flag, separate from the existing --type-inlays
.