MiniZinc / libminizinc

The MiniZinc compiler
http://www.minizinc.org
Other
516 stars 81 forks source link

Evaluation error of arrays in comprehension assignment #858

Open CervEdin opened 1 month ago

CervEdin commented 1 month ago

If I use assignment of arrays in comprehensions like this

array[int, int] of int: foos = [| 1, 0 |];

output [
  show([ r[1] | t=foos, i in index_set_1of2(t), r=t[i, ..] ]), % error
  show([ r[1] | i in index_set_1of2(foos), t=foos, r=t[i, ..] ]), % error
  show([ r[1] | i in 1..1, t=foos, r=t[i, ..] ]), % error
  "\n",
];

playground.mzn%2C%20%25%20error%5Cn%20%20%5C%22%5C%5Cn%5C%22%2C%5Cn%5D%3B%22%7D%5D%2C%22tab%22%3A0%2C%22solverId%22%3A%22org.minizinc.gecode_presolver%22%2C%22solverConfig%22%3A%7B%22enableTimeLimit%22%3Afalse%2C%22timeLimit%22%3A1%2C%22allSolutions%22%3Afalse%2C%22verboseCompilation%22%3Afalse%2C%22verboseSolving%22%3Afalse%2C%22compilerStatistics%22%3Afalse%2C%22solvingStatistics%22%3Afalse%2C%22outputTime%22%3Afalse%2C%22freeSearch%22%3Afalse%7D%2C%22minizincVersion%22%3A%22latest%22%7D)

I end up with

MiniZinc: evaluation error: index_set: wrong dimension

in MiniZinc 2.8.4+ in MiniZinc 2.8.3- it's instead

Error: evaluation error: arrays of arrays not supported

Possibly related to issue #807

CervEdin commented 1 month ago

interestingly, this is OK

  show([ r | i in index_set_1of2(foos), t=foos, r=t[i, 1] ]), % OK

but this is not

  show([ r | t=foos, i in index_set_1of2(t), r=t[i, 1] ]), % error