Skip to content

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

Closed
@matsc-at-sics-se

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, {}];
----------

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions