Index assign broken on empty arrays
This failure is recent, as the apex unit tests ran clean about a week ago. Here is crud.sac:
Use Array: {genarray,shape,sel};
int main()
{
y = [true];
cell = genarray([0], false);
z = with {
(. <= iv <= .)
: genarray([0], y[iv]);
} : genarray(shape(y), cell);
StdIO::print(z);
return(0);
}
In APL, we have:
x←1 0⍴42 ⍝ create empty matrix
x
⍴x
1 0
x[0;]←444 ⍝ Set all rows to 444
x
⍴x
1 0
x[0;]←,444 ⍝ Same, but with matching shapes.
x
In SaC, we have this:
sac2c_d -V
sac2c 1.3.3-MijasCosta-1071-g2abb8
build-type: DEBUG
built-by: "sac" at 2023-05-17T16:49:06
apex@medusa:~/apexgit/Ancillary/benchmks/UnitTests/UTCompress/crud$ sac2c_d crud.sac
** 1: Loading SAC program ...
** 2: Preprocessing SAC program ...
** 3: Running module system ...
** 4: Simplifying source code ...
** 5: Converting to static single assignment form ...
** 6: Running type inference system ...
** 7: Processing exports ...
** 8: Preparing for code optimization ...
** 9: Enhancing with-loops ...
** 10: Running SAC optimizations ...
Internal compiler error
Assertion "n < TCcountExprs (exprs)" failed at /home/sac/sac2c/src/libsac2c/tree/tree_compound.c:1696 -- Expected at least 1th exprs but found 0 expressions.
The compile dies in SCCFprf_modarray_AxVxA, in the call to TCgetNthExprs, trying to obtain an N_exprs node from an empty argument. I think the TCgetNthExprs code (and friends) is correct, and that the modarray() code is broken for PRF_ARG3 a non-scalar.
Commit 42cefbb0 says "TCgetNthExprsExpr is now non-nullable". but that statement makes no sense to me. E.g., it could mean "...will never return a NULL result", or it could mean something else.