chapel icon indicating copy to clipboard operation
chapel copied to clipboard

dyno: resolving `init` of generic record causes assertion failure

Open DanilaFe opened this issue 10 months ago • 2 comments

This comes up when trying to resolve chpl_build_bounded_range, which is how the production compiler resolves range literals like 1..10. The minimal reproducer is as follows:

record myRange {
  type idxType;

  proc init(type idxType) {}
}

var rng = new myRange(int);

Likely this should be an error (idxType isn't being set by the constructor). If I add this.idxType = idxType to the body of the init, the code above goes through. However, I'm also getting this while trying to resolve a plain range.init, which does properly set idxType:

  proc range.init(type idxType, low: idxType, high: idxType) {
    this.idxType = idxType;
    this.bounds = boundKind.both;
    this._low = chpl__idxToInt(low);
    this._high = chpl__idxToInt(high);
  }

So, the two TODOs are:

  1. Figure out why range.init is throwing an assertion here, despite having idxType set.
  2. Make this not be an assertion error.

DanilaFe avatar Apr 10 '24 00:04 DanilaFe