chapel-lang / chapel

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

Another internal compiler error with lambdas #18636

Open twesterhout opened 2 years ago

twesterhout commented 2 years ago

Summary of Problem

Compilation fails with an internal compiler error.

Steps to Reproduce

Source Code:

proc merge(xs: [?Dom] ?eltType, ys: []) {
  const count = xs.size + ys.size;
  var dst: [0..#count] eltType;
  if (xs.size == 0) { dst = ys; return dst; }
  if (ys.size == 0) { dst = xs; return dst; }

  var i_xs = 0;
  var i_ys = 0;
  var i = 0;
  var writeFromFirst = lambda() {
    dst[i] = xs[i_xs];
    i_xs += 1;
    i += 1;
  };
  var writeFromSecond = lambda() {
    dst[i] = ys[i_ys];
    i_ys += 1;
    i += 1;
  };
  while (i < count) {
    if (xs[i_xs] <= ys[i_ys]) { writeFromFirst(); }
    else { writeFromSecond(); }
  }
  return dst;
}

proc main()
{
  var x = merge([1, 7, 8], [5, 11]);
}

p.s. don't mind the code itself, it's incorrect. This shouldn't cause the compiler to crash though.

Configuration Information

bradcray commented 2 years ago

Belatedly, thanks for filing this Tom.