chocoteam / choco-solver

An open-source Java library for Constraint Programming
http://choco-solver.org/
BSD 4-Clause "Original" or "Old" License
690 stars 143 forks source link

[BUG] Choco-solver 4.10.13: index out of bounds #1036

Closed matsc-at-sics-se closed 1 year ago

matsc-at-sics-se commented 1 year ago

In search annotations, the list of variables can be empty as a result of list comprehension depending on input parameters or in automatically generated models. For example, the following is expected to merely succeed:

$ cat lat.mzn
solve :: int_search([], largest, indomain_random, complete) satisfy;

$ minizinc --solver choco lat.mzn
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at org.chocosolver.parser.flatzinc.ast.searches.IntSearch.valueSelector(IntSearch.java:90)
    at org.chocosolver.parser.flatzinc.ast.searches.IntSearch.build(IntSearch.java:41)
    at org.chocosolver.parser.flatzinc.ast.FGoal.readSearchAnnotation(FGoal.java:134)
    at org.chocosolver.parser.flatzinc.ast.FGoal.define_goal(FGoal.java:85)
    at org.chocosolver.parser.flatzinc.Flatzinc4Parser.solve_goal(Flatzinc4Parser.java:1376)
    at org.chocosolver.parser.flatzinc.Flatzinc4Parser.flatzinc_model(Flatzinc4Parser.java:244)
    at org.chocosolver.parser.flatzinc.Flatzinc.parse(Flatzinc.java:194)
    at org.chocosolver.parser.flatzinc.Flatzinc.buildModel(Flatzinc.java:147)
    at org.chocosolver.parser.flatzinc.ChocoFZN.main(ChocoFZN.java:27)
cprudhom commented 1 year ago

Commit 0e932443cb55e56726f35f585c61e1205bdcd518 @matsc-at-sics-se Thank you for the bug report