chocoteam / chocoteam/choco-solver
[BUG] MiniZinc parser crashes on a model with float vars
- Dominant language
- Java
- Stars
- 779
- Forks
- 159
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 10
Description
**Describe the bug**
Consider the following MiniZinc model:
```
var -100.0..100.0: x;
var -100.0..100.0: y;
constraint 2 * x + 3 * y >= 10;
solve satisfy;
```
When I run Choco on this model in MiniZinc IDE, it crashes with the following stacktrace:
```
%% Choco 231102
line 1:44 mismatched input '.' expecting {',', ']'}
Exception in thread "main" java.lang.UnsupportedOperationException: Parameter#buildArray ARRAY: unexpected type for X_INTRODUCED_2_
at org.chocosolver.parser.flatzinc.ast.FParameter.buildArray(FParameter.java:162)
at org.chocosolver.parser.flatzinc.ast.FParameter.make_parameter(FParameter.java:49)
at org.chocosolver.parser.flatzinc.Flatzinc4Parser.param_decl(Flatzinc4Parser.java:1168)
at org.chocosolver.parser.flatzinc.Flatzinc4Parser.flatzinc_model(Flatzinc4Parser.java:212)
at org.chocosolver.parser.flatzinc.Flatzinc.parse(Flatzinc.java:199)
at org.chocosolver.parser.flatzinc.Flatzinc.buildModel(Flatzinc.java:152)
at org.chocosolver.parser.flatzinc.ChocoFZN.main(ChocoFZN.java:27)
```
It looks like the line `array [1..2] of float: X_INTRODUCED_2_ = [-2.0,-3.0];` in generated flatzinc representation kills the parser. When I change the variables to ints it works.
**Environment (please complete the following information):**
- Choco-solver 4.10.14 (I found no related commits since the release, so the bug is probably still around)
- MiniZinc IDE 2.8.4
- JRE 22.0.1
- Windows 10
Contributor guide
Assessment
This issue has not been assessed yet.