chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.76k stars 414 forks source link

[Bug]: Type inlay hints are printed incorrectly for several types #25113

Open jabraham17 opened 1 month ago

jabraham17 commented 1 month ago

There are a number of type inlay hints that render incorrectly in CLS. I suspect some of these are due to the resolver not being finished and will be resolved in time, but I want to capture them here

Ranges. The correct inlay is more up for debate here, as I think its way too verbose to be useful. Certainly, we should not be printing dyno IDs, but enums are currently always printed this way

var r /*: _range(int(64), ChapelRange.boundKind@2, ChapelRange.strideKind@2)*/ = 1..10;

/* possible correct inlays
range(int(64), both, one)
range(int(64), boundKind.both, strideKind.one)
range(int(64)) // hide the defaults
*/

Split init with generics

record Generic {
  type t;
  var x: t;
  proc init(type t) {
    this.t = t;
  }
}

var x: Generic(?);
x = new Generic(int);
var y /*: Generic*/ = x; // should be Generic(int(64))

User-defined generic classes. This works properly with records

class Concrete {
  var x: int;
}
class Generic {
  type t;
  var x: t;
  proc init(type t) {
    this.t = t;
  }
}
var a/*: owned Generic*/ = new Generic(Concrete); // should be owned Generic(Concrete)
var b/*: owned Generic*/  = new Generic(Generic(string)); // should be owned Generic(Generic(string))

Missing type inlays for arrays/domains. This is solidly in the "resolver is not done" camp of issues

var a = [1,2,3]; // type inlay for array missing
var b = {1..10}; // type inlay for domain missing

Iterators

iter foo() {
  yield 1;
  yield 2;
  yield 3;
}
var a /*: int(64) */ = foo(); // should be an array type, possibly some sort of iterable type?
DanilaFe commented 3 weeks ago
var x: Generic(?);
x = new Generic(int);
var y /*: Generic*/ = x; // should be Generic(int(64))

Curiously, testInteractive reports the types of both x and y as Generic (not Generic(int)), so it's surprising that x show as Generic(int).

typehints@10                Identifier x : var Generic ;  refers to typehints@3
typehints@11                  Variable y : var Generic ;

So this is likely a bug with accessing a split-initialized variable.