libminizinc icon indicating copy to clipboard operation
libminizinc copied to clipboard

showJSON encodes array of enum inside record as array of int

Open CervEdin opened this issue 1 year ago • 0 comments

Given the following model.mzn

enum e = { A };

array[int] of e: As = [ A ];
record( array[int] of e: as ): foo = (as: As);

output [
  showJSON(foo), "\n",
  showJSON(As),
];

Expected output

{"as": [{"e":"A"}]}
[{"e":"A"}]
----------

Actual output

{"as": [1]}
[{"e":"A"}]
----------

I expected that the array[int] of e, inside the record, would be encoded as a array[int] of e instead it's encoded as an array[int] of int. Thinking this is maybe a bug.

This was observed in

MiniZinc to FlatZinc converter, version 2.7.6, build 905165378

running on

Ubuntu 22.04.3 LTS
Linux 5.15.133.1-microsoft-standard-WSL2

CervEdin avatar Feb 28 '24 16:02 CervEdin