libminizinc icon indicating copy to clipboard operation
libminizinc copied to clipboard

empty set as default value for optional set fails

Open CervEdin opened this issue 1 year ago • 2 comments

The following model:

enum foo = {A,B,C};
opt set of foo: bar;
set of foo: biz = bar default {};
output show(biz)

fails with

MiniZinc: type error: ambiguous overloading on return type of function

CervEdin avatar Apr 22 '24 10:04 CervEdin

This is probably more to do with the opt set - these are currently not really supported (they happen to work sometimes by coincidence, but there seem to be many places where they don't).

We'll have a look at whether it's possible to make this work, or otherwise make the type checker give a proper error for opt sets.

cyderize avatar Apr 22 '24 23:04 cyderize

Aha. Yeah, I've been a bit curious about why it was possible to have an opt set but not an opt array[_]. I see int the spec that option types may be

Allowed Insts. The argument of an option type must be one of the base types bool, int or float.

Sounds like we're using something that's not officially supported, and working by accident. Am I understand that correctly?

As a user, I would add that option types that include sets, arrays parameters etc. would be useful in the language as it allows for introducing parameters which are backwards compatible.

CervEdin avatar Apr 23 '24 07:04 CervEdin