Skip to content

MiniZinc too pedantic about the type of an empty list? #664

Description

@matsc-at-sics-se

The following happens in all versions that I have tried.
If it's not a bug, it's certainly non-intuitive.

$ cat bug1.mzn 
array[1..3] of set of int: C = [{1},{2},{3}];
array[int] of set of int: F(int: t) =
  if t = 3 then [] else [C[t+1] | _ in 1..2] ++ F(t+1) endif;
output ["F = \(F(0));\n"];
$ minizinc bug1.mzn 
Error: type error: type mismatch in branches of conditional. `then' branch has type `array[int] of bot', but `else' branch has type `array[int] of set of int'
/home/matsc/Coursera/Ass8/models/bug1.mzn:3.17-18
$ cat bug2.mzn 
array[1..3] of set of int: C = [{1},{2},{3}];
array[int] of set of int: F(int: t) =
  if t = 3 then [{}] else [C[t+1] | _ in 1..2] ++ F(t+1) endif;
output ["F = \(F(0));\n"];
$ minizinc bug2.mzn 
F = [1..1, 1..1, 2..2, 2..2, 3..3, 3..3, {}];
----------

Activity

  1. added a commit that references this issue on Apr 5, 2023
    e29be1a
  2. added
    resolvedIssue is resolved and the feature or fix will be part of next release
    on Apr 5, 2023
  3. added theissue type on Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    resolvedIssue is resolved and the feature or fix will be part of next release

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions