enum field parsing error in array of records

14 views
Skip to first unread message

Andrey Rybalchenko

unread,
May 21, 2024, 11:40:06 AMMay 21
to MiniZinc
Hi, 

Below combination of mzn and json throws
Error: type error: cannot determine coercion from type string to type E

Inlining the type definition makes the json parser happy, however, in my mzn inlining all the nested records is not very attractive.

Any thoughts if there is a fix planned?

Thanks,
Andrey


enum E;
type R = record(E: fld);
array [_] of R: rs;

{
  "E": ["E1", "E2"],
  "rs": [
    {"fld": "E1"},
    {"fld": "E2"}
  ]
}

Jip Dekker

unread,
May 22, 2024, 8:07:33 AMMay 22
to MiniZinc
Hi Andrey,

The issue is that the type aliases are resolved after the JSON is parsed and the JSON parser relies on the (currently incomplete) type information of the model.
Resolving the type aliases before parsing the JSON should solve this issue, but it would require disconnecting this process from the current type checking process.
It is certainly something I would like to solve, but would require quite a bit of engineering, so I'll need to see when I have time.

Cheers,
Jip
Reply all
Reply to author
Forward
0 new messages